Skip to content
This repository was archived by the owner on Apr 14, 2024. It is now read-only.

Commit 560a211

Browse files
committed
Fixed possible file-handle leak
Configured travis to artificially restrict handle count to protect from regression in that regard
1 parent 9b3a34b commit 560a211

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

.travis.yml

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ git:
1212
install:
1313
- pip install coveralls
1414
script:
15+
- ulimit -n 48
16+
- ulimit -n
1517
- nosetests -v --with-coverage
1618
after_success:
1719
- coveralls

gitdb/stream.py

+11-3
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,7 @@ def _set_cache_(self, attr):
9191
self._parse_header_info()
9292

9393
def __del__(self):
94-
if self._close:
95-
self._m.close()
96-
# END handle resource freeing
94+
self.close()
9795

9896
def _parse_header_info(self):
9997
"""If this stream contains object data, parse the header info and skip the
@@ -141,6 +139,16 @@ def data(self):
141139
""":return: random access compatible data we are working on"""
142140
return self._m
143141

142+
def close(self):
143+
"""Close our underlying stream of compressed bytes if this was allowed during initialization
144+
:return: True if we closed the underlying stream
145+
:note: can be called safely
146+
"""
147+
if self._close:
148+
self._m.close()
149+
self._close = False
150+
# END handle resource freeing
151+
144152
def compressed_bytes_read(self):
145153
"""
146154
:return: number of compressed bytes read. This includes the bytes it

0 commit comments

Comments
 (0)