-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Image.save() does not close file pointer #2760
Comments
Skipping the CV2/NumPy process entirely and using PIL alone, like this:
Produces the same error, but with a different traceback:
|
The tracebacks aren't going to be much use, since they are triggering on the last attempt to open a file, not which files remain unclosed. Can you get a list of open files from the OS somewhere? I suspect that the trouble is still in the open side. Can you try this:
And on one of the images, check if img.readonly and img.map are set? |
I don't fully know what I'm doing, but using Process Explorer I can't find any indication that the process has more than one file handle open to an image at any given time. In fact, it explicitly shows each file handle exiting in turn (turning red in the handles frame) before a new one is opened.
The value of |
So does it run to completion without the save? Or does it eventually die in opening? |
My god, I'm sorry, this isn't a Pillow issue at all. I thought I had a sterile test environment, but I was still wrapping this whole process in a context manager to suppress "deep" stdout and stderr content. The instance created by this context manager was redirecting stdout and stderr to null files and then failing to properly clean up after itself. Thank you for your time and help. |
What did you do?
I'm modifying a large number of single-page tiffs as NumPy arrays and saving each to file individually via Image.fromarray. For example:
What did you expect to happen?
I expected the full list of images to be read into arrays in turn by OpenCV & NumPy and saved as TIFFs by Pillow.
What actually happened?
After exactly 1020 successful iterations, I get the following error:
What versions of Pillow and Python are you using?
Python v3.4.4 (x64) on Windows 7
Pillow 4.2.1
What have you tried?
I have tried enclosing img.save() in a context manager, as well as explicitly closing the file pointer (if that's even possible or relevant here?), e.g.
I have also seen and reviewed the following issues, and have not been able to successfully implement their workarounds. This case seems to be different due to the lack of calling either Image.open() or Image.load().
The text was updated successfully, but these errors were encountered: