This warning was added in python 3.2 and is triggered by allowing the reference count of an opened file to go to zero -- in this case stream in IndexFile._store_path.
Is it safe to call stream.close() after the istream object is created?
Sorry for the late reply.
The IndexFile implementation doesn't take ownership if the passed-in streams, and therefore just expects them to be readable until EOF.
There is not a single close call on streams in the implementation.
To answer your question: Yes, it should be safe to close your own streams, and it's even recommended to prevent leakage.
However, your question raises my fear that in python 3, resource handling won't work anymore. Usually you could assume that file handles/streams are closed when they are dropped, but as __del__() now only gets called sometime, calls to add() could cause exceeding the maximum amount of concurrently open files of the python process.
Activity
Byron commented on Feb 23, 2015
Sorry for the late reply.
The IndexFile implementation doesn't take ownership if the passed-in streams, and therefore just expects them to be readable until EOF.
There is not a single close call on streams in the implementation.
To answer your question: Yes, it should be safe to close your own streams, and it's even recommended to prevent leakage.
However, your question raises my fear that in python 3, resource handling won't work anymore. Usually you could assume that file handles/streams are closed when they are dropped, but as __del__() now only gets called sometime, calls to add() could cause exceeding the maximum amount of concurrently open files of the python process.
Byron commented on Apr 8, 2015
You can watch the development stream on youtube.