Close streamed file in file_generator on destruct
@@ -70,6 +70,11 @@ class file_generator(object):
raise StopIteration()
next = __next__
+ def __del__(self):
+ """Close input on descturct."""
+ if hasattr(self.input, 'close'):
+ self.input.close()
+
def file_generator_limited(fileobj, count, chunk_size=65536):
"""Yield the given file object in chunks.
