-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Too Many Open Files when working with Tiffs (issue with files being closed) #6985
Comments
Just to link, this is a new report of #6671 |
It would be interesting if anyone knows why 8187 is the magic number here. |
https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/setmaxstdio
They probably have five other files open somewhere. 8187 + 5 = 8192. |
I’ve tested the pull request in #6986 with a couple of sets of files and this has resolved the Too many open files error. So long as this hasn’t introduced any unexpected issues then I think this issue can be closed. |
What did you do?
I am using os.walk to pattern match files in folders, reducing the size of images using pillow and saving them to a temporary folder, eventually merging these to a PDF. I have narrowed the issue down to the Pillow compression as Without the pillow compression, the process completes for many hundreds of thousands of images but when using the pillow compression it stops consistently with [Errno 24] Too many open files on file 8187.
This happens in VS Code and an Anaconda Powershell on different computers in different python environments and in pillow 9.2.0 and 9.4.0.
What did you expect to happen?
Images would be opened, saved and closed using the context manager where conditions are met. This works until the script stops with [Errno 24] Too many open files.
What actually happened?
The process stops at the same point every time (after successfully processing 8186 files) with [Errno 24] Too many open files.
I think this is similar to the issue shown in #5936 where the tiff files are not being closed.
Unfortunately, I have many hundreds of thousands of files to process. I've tried all the suggestions on #5936 Could something have re-introduced this issue?
What are your OS, Python and Pillow versions?
I have provided a working example using only the compression function.
Working example
Code with an example 20kb image is included: Pil.zip
This throws the exception [Errno 24] Too many open files on file 8187 on both an i7, 16GB ram and a Xeon, 128GB ram.
The text was updated successfully, but these errors were encountered: