diff options
author | Duncan Bellamy <dunk@denkimushi.com> | 2021-01-17 03:02:24 +0100 |
---|---|---|
committer | Sviatoslav Sydorenko <wk@sydorenko.org.ua> | 2021-01-17 03:02:24 +0100 |
commit | 59c0e19d7df8680e36afc96756dce72435121448 (patch) | |
tree | 8f8698889d52f6856ac285bfde9cf1a69d2e1ee6 /cherrypy | |
parent | 3bae7f06868553b006915f05ff14d86163f59a7d (diff) | |
download | cherrypy-git-59c0e19d7df8680e36afc96756dce72435121448.tar.gz |
Close streamed file in file_generator on destruct
Diffstat (limited to 'cherrypy')
-rw-r--r-- | cherrypy/lib/__init__.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/cherrypy/lib/__init__.py b/cherrypy/lib/__init__.py index f815f76a..0edaaf20 100644 --- a/cherrypy/lib/__init__.py +++ b/cherrypy/lib/__init__.py @@ -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. |