Looping video in gstreamer, getting "too many files open"

I am trying to loop a video using the example code and gstreamer:

class SomeClass(object):

     def video_call(self):

          GObject.threads_init()
          Gst.init(None)

          self.playbin = Gst.ElementaryFactory.make("playbin", None)

          uri = Gst.filename_to_uri("CES_AE_3D.mp4")
          self.playbin.set_property('uri', uri)

          self.loop = GObject.MainLoop()

          bus = self.playbin.get_bus()
          bus.add_signal_watch()
          bus.connect("message", self.bus_call, self.loop)

        self.playbin.set_state(Gst.State.PLAYING)
        try:
            self.loop.run()
        except:
               pass

          set.playbin_set_state(Gst.State.NULL)

    def loop_control(self):
        while True:
             if condition_var:
                  self.video_call()

This is a simplified version of the code, with bus_call method as well. And everything works fine, but then after 5 minutes I get an error along the lines of:

Any solutions would be helpful.

Hi,
For information, please share release version:

$ head -1 /etc/nv_tegra_release

And share what elements are used in playbin by setting:

$ export GST_DEBUG=*FACTORY*:4

I am getting same error “Too many open files” on jetson nano.
For me the output of $ head -1 /etc/nv_tegra_release is

R32 (release), REVISION: 3.1, GCID: 18186506, BOARD: t210ref, EABI: aarch64, DATE: Tue Dec 10 06:58:34 UTC 2019

And by setting: $ export GST_DEBUG=FACTORY:4, I get output of my code as

0:00:31.702954726 12024 0x202d2680 INFO GST_ELEMENT_FACTORY gstelementfactory.c:361:gst_element_factory_create: creating element “udpsrc”

I am reading rtsp stream using below function

def open_cam_rtsp(uri, width, height, latency):
gst_str = ('rtspsrc location={} latency={} ! ’
'rtph264depay ! h264parse ! omxh264dec ! ’
'nvvidconv ! ’
'video/x-raw, width=(int){}, height=(int){}, ’
'format=(string)BGRx ! ’
‘videoconvert ! appsink’).format(uri, latency, width, height)
return cv2.VideoCapture(gst_str, cv2.CAP_GSTREAMER)

Any suggestions how to get rid of this “Too many open files” error?

Hi,
We are deprecating omx plugins. Please try nvv4l2decoder. You can refer to C samples(opencv_gst_samples_src.tbz2) in
https://developer.nvidia.com/embedded/L4T/r32_Release_v4.2/Sources/T210/public_sources.tbz2

Thank you, removing omxh worked for me.