diff options
| author | Sebastian Thiel <byronimo@gmail.com> | 2015-01-07 18:09:45 +0100 |
|---|---|---|
| committer | Sebastian Thiel <byronimo@gmail.com> | 2015-01-07 18:09:45 +0100 |
| commit | 560a211001064261eb25ca874980591790fb7986 (patch) | |
| tree | fd99b876759d023d18c6cb17b350f51469022f5a /gitdb | |
| parent | 9b3a34b7d00285cf9028d19e82de6b155d0096c7 (diff) | |
| download | gitdb-560a211001064261eb25ca874980591790fb7986.tar.gz | |
Fixed possible file-handle leak
Configured travis to artificially restrict handle count to protect
from regression in that regard
Diffstat (limited to 'gitdb')
| -rw-r--r-- | gitdb/stream.py | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/gitdb/stream.py b/gitdb/stream.py index 4478a0f..d855257 100644 --- a/gitdb/stream.py +++ b/gitdb/stream.py @@ -91,9 +91,7 @@ class DecompressMemMapReader(LazyMixin): self._parse_header_info() def __del__(self): - if self._close: - self._m.close() - # END handle resource freeing + self.close() def _parse_header_info(self): """If this stream contains object data, parse the header info and skip the @@ -141,6 +139,16 @@ class DecompressMemMapReader(LazyMixin): """:return: random access compatible data we are working on""" return self._m + def close(self): + """Close our underlying stream of compressed bytes if this was allowed during initialization + :return: True if we closed the underlying stream + :note: can be called safely + """ + if self._close: + self._m.close() + self._close = False + # END handle resource freeing + def compressed_bytes_read(self): """ :return: number of compressed bytes read. This includes the bytes it |
