So most OSs have a limited number of handles, but CPython will close the file descriptors when they leave scope. What you could do to fix it is just have a FilePoolManager that checks the refcounts explicitly, probably a bit premature to do that yet (and way to java-y).