python: Too many open files

Mathieu Duponchelle mathieu at centricular.com
Mon Jan 25 15:15:11 UTC 2021


Good :) I strongly advise using GstPlayer anyways, it gets a lot of tricky things
right.

On 1/24/21 11:03 AM, Patrick Shirkey wrote:
>
> For reference I found that adding the following to the lplayer.py stopped the file descriptor leaks.
>
>     def set_filename(self, filename, jack_name):
>         if self.player is not None:
>             self.player.set_state(Gst.State.NULL)
>
>         bus = self.player.get_bus()
>         bus.remove_signal_watch()
>         self.player = self.get_player(jack_name)
>         self.player.get_by_name('urisrc').set_property('uri', 'file://' + filename)
>
>
> ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
> On Saturday, January 23, 2021 11:10 AM, Patrick Shirkey <patrickshirkey at protonmail.com> wrote:
>
>> Thanks Mattieu. 
>>
>> That was the hint I needed. Seems that the lplayer method with Gst instead of GstPlayer is leaking the stream file descriptor. In case anyone has the inclination to look into it further, I noticed it increments by three at play() and decrements by two at stop(). 
>>
>> https://github.com/atareao/lplayer/blob/master/src/lplayer/player.py <https://github.com/atareao/lplayer/blob/master/src/lplayer/player.py>
>>
>>
>>
>> ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
>> On Friday, January 22, 2021 10:10 PM, Mathieu Duponchelle <mathieu at centricular.com> wrote:
>>
>>> GstPlayer can be used from python, and probably fits your use case :)
>>>
>>>  meh   master  ~  devel  gst-build  ipython3
>>> Python 3.8.6 (default, Sep 25 2020, 00:00:00) 
>>> Type 'copyright', 'credits' or 'license' for more information
>>> IPython 7.12.0 -- An enhanced Interactive Python. Type '?' for help.
>>> In [1]: from gi.repository import Gst                                                                                                                                                                                                                                                     
>>> <ipython-input-1-4132414128eb>:1: PyGIWarning: Gst was imported without specifying a version first. Use gi.require_version('Gst', '1.0') before import to ensure that the right version gets loaded.
>>>   from gi.repository import Gst
>>> In [2]: Gst.init(None)                                                                                                                                                                                                                                                                    
>>> Out[2]: []
>>> In [3]: from gi.repository import GstPlayer                                                                                                                                                                                                                                               
>>> <ipython-input-3-b10918504373>:1: PyGIWarning: GstPlayer was imported without specifying a version first. Use gi.require_version('GstPlayer', '1.0') before import to ensure that the right version gets loaded.
>>>   from gi.repository import GstPlayer
>>> In [4]: p = GstPlayer.Player()                                                                                                                                                                                                                                                            
>>> In [5]: p.set_uri('file:///home/meh/Music/chaplin.wav')                                                                                                                                                                                                                                   
>>> In [6]: p.play()                                                                                                                                                                                                                                                                          
>>> In [7]: p.set_uri('file:///home/meh/Music/biggie.wav')                                                                                                                                                                                                                                    
>>> In [8]: p.play()                                                                                                                                                                                                                                                                          
>>> On 1/22/21 7:27 PM, Patrick Shirkey wrote:
>>>>
>>>> Yes, I am using python for this project and this script meets all of my requirements except for the file descriptor leak.
>>>>
>>>> Is there a specific step required before/after loading a new audio file with:
>>>> self.player.get_by_name('urisrc').set_property('uri', 'file://' + filename)
>>>>
>>>>
>>>>
>>>>
>>>> -------- Original Message --------
>>>> On Jan 22, 2021, 7:04 PM, Mathieu Duponchelle < mathieu at centricular.com <mailto:mathieu at centricular.com>> wrote:
>>>>
>>>>
>>>>     Hey, are you aware of the existence of gst-player?
>>>>
>>>>     https://gstreamer.freedesktop.org/documentation/player/gstplayer.html?gi-language=c <https://gstreamer.freedesktop.org/documentation/player/gstplayer.html?gi-language=c>
>>>>
>>>>     Cheers,
>>>>
>>>>
>>>>     -- 
>>>>     Mathieu Duponchelle · https://www.centricular.com <https://www.centricular.com>
>>>>
>>>>     On 1/22/21 5:01 PM, Patrick Shirkey wrote:
>>>>>     Hi,
>>>>>
>>>>>     I am using this simple python script to play audio files:
>>>>>
>>>>>     https://github.com/atareao/lplayer/blob/master/src/lplayer/player.py <https://github.com/atareao/lplayer/blob/master/src/lplayer/player.py>
>>>>>
>>>>>     specifically
>>>>>
>>>>>     85: get_player()
>>>>>     135: play()
>>>>>     172: stop()
>>>>>
>>>>>
>>>>>     Any ideas on why I get 2 additional STREAM file descriptors every time I play a new track eventually resulting in "Too many open files" error and segfault?
>>>>>
>>>>>     ex.  44u     unix 0x000000008179a133       0t0  100262669 type=STREAM
>>>>>
>>>>>
>>>>>     --
>>>>>     Patrick Shirkey
>>>>>
>>>>>
>>>>>
>>>>>     _______________________________________________
>>>>>     gstreamer-devel mailing list
>>>>>     gstreamer-devel at lists.freedesktop.org <mailto:gstreamer-devel at lists.freedesktop.org>
>>>>>     https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel <https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel>
>>>>>
>>>>
>>>> _______________________________________________
>>>> gstreamer-devel mailing list
>>>> gstreamer-devel at lists.freedesktop.org <mailto:gstreamer-devel at lists.freedesktop.org>
>>>> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel <https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel>
>>>>
>>
>
>
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20210125/e20f192a/attachment-0001.htm>


More information about the gstreamer-devel mailing list