Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Fix: close image files after use during palette check #68
With pypy, nmlc trivially trips file handle limits on macOS during palette checks, resulting in: "[Errno 24] Too many open files".
This is a common enough problem in python, which can be resolved by either
This PR closes images opened for palette checks, which is a trivial case. Errno 24 no longer triggers for me. Tests pass.
Errno 24 does not trigger for me with any cPython 3.x, but pypy cuts run times by up to 50% in my testing compared to cPython 3.8, so we do want to be compatible with pypy.
There are a couple of other uses of Image.open() but they looked less trivial, and they're not tripping Errno 24 for me.
For the record,
I agree with fsj: the closing should be done by means of using the with contextmanager