Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
Fix file-handle resource leaks #9309
Issue #9287: Resource leak of file handles
Open resources (ordinary file, HDF5, tar, urlopen response, etc.) were often not closed properly. When an exception is raised the resource might not be closed. This may eg. result in depleting the number of file handles for the process.
Where possible use context managers (
PIL images returned by
with keras.preprocess.image.load_img(...) as img: # do something with the image # image closed...
However, I'm not 100% sure if this can be disturbed by operations such as