Too many open files error

15 views
Skip to first unread message

Sonam Singh

unread,
Apr 15, 2016, 6:36:23 PM4/15/16
to imageio
I have many avi files.
for i,row in  files:
        path=row
        f=path
        with imageio.get_reader(path) as read:
            ims=[]
            for j,im in enumerate(read):
                ims.append(im)

        act = np.array(ims)
        
        np.save('out/'+f, act)
after reading 300+  avi files, I am getting runtime error : too many open files.
I want to convert avi files to numpy array for further processing,
If i am not wrong, isn't the context manger ('with') should be dealing with it? also, forcefully closing with read.close doesn't help either.

Any ideas?

-Sonam



Almar Klein

unread,
Apr 17, 2016, 9:00:31 AM4/17/16
to Sonam Singh, imageio

Yes, the context manager should calls `_close()` on the reader object, which, for the ffmpeg reader calls `_terminate()`, which should terminate the ffmpeg process. Looking at the code, everything seems to be in order, but maybe something is holding onto the process somehowe.

 

If you feel like diving in, you could play around here (https://github.com/imageio/imageio/blob/master/imageio/plugins/ffmpeg.py#L380-L395) to e.g. check that it is indeed called for each file, or kill the process if we failed to stop it the “nice way”.

 

Also, have you tried commenting the `np.save()` to be sure its imageio?

 

If the problem persists, can you please make an issue on the issue tracker on Github?

 

Thanks,

  Almar

--
You received this message because you are subscribed to the Google Groups "imageio" group.
To unsubscribe from this group and stop receiving emails from it, send an email to imageio+u...@googlegroups.com.
To post to this group, send email to ima...@googlegroups.com.
Visit this group at https://groups.google.com/group/imageio.
For more options, visit https://groups.google.com/d/optout.

 

Reply all
Reply to author
Forward
0 new messages