Skip to content

Commit

Permalink
refact(minor): use region.priv-func, close fd on same condition
Browse files Browse the repository at this point in the history
  • Loading branch information
ankostis committed Oct 25, 2016
1 parent 7c1eac7 commit bba086a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions smmap/mman.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,9 +319,11 @@ def _collect_lru_region(self, size):
lru_list = None
for regions in self._fdict.values():
for region in regions:
# check client count - if it's 1, it's just us
## Check client count - if it's 1, it's just us.
#
if (region.client_count() == 1 and
(lru_region is None or region._uc < lru_region._uc)):
(lru_region is None or
region.client_count() < lru_region.client_count())):
lru_region = region
lru_list = regions
# END update lru_region
Expand Down
2 changes: 1 addition & 1 deletion smmap/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def __init__(self, path_or_fd, ofs, size, flags=0):
self._mfb = buffer(self._mf, ofs, self._size)
# END handle buffer wrapping
finally:
if isinstance(path_or_fd, string_types()):
if not isinstance(path_or_fd, int):
os.close(fd)
# END only close it if we opened it
# END close file handle
Expand Down

0 comments on commit bba086a

Please sign in to comment.