summaryrefslogtreecommitdiff
path: root/numpy/core/memmap.py
diff options
context:
space:
mode:
authorTravis Oliphant <oliphant@enthought.com>2007-09-21 17:14:57 +0000
committerTravis Oliphant <oliphant@enthought.com>2007-09-21 17:14:57 +0000
commit1091b67a91c4e87a2304bd203b30800088f0e86e (patch)
tree18eeae38bce0fe99219758b2af49a8f6fd4c333c /numpy/core/memmap.py
parenta64b5f0ee524a52cdb65fa8ae3dce1a18b58b589 (diff)
downloadnumpy-1091b67a91c4e87a2304bd203b30800088f0e86e.tar.gz
Fix memmap passing on it's mmap attribute to views but not closing the file unless it owns the memmap
Diffstat (limited to 'numpy/core/memmap.py')
-rw-r--r--numpy/core/memmap.py10
1 files changed, 4 insertions, 6 deletions
diff --git a/numpy/core/memmap.py b/numpy/core/memmap.py
index 831ba3307..3650091bc 100644
--- a/numpy/core/memmap.py
+++ b/numpy/core/memmap.py
@@ -80,10 +80,7 @@ class memmap(ndarray):
if obj is not None:
if not isinstance(obj, memmap):
raise ValueError, "Cannot create a memmap array that way"
- # it would be nice to carry the along the _mmap name
- # but then we might have problems because self could close
- # it while obj is still holding it. So, we don't do
- # anything at this point.
+ self._mmap = obj._mmap
else:
self._mmap = None
@@ -91,9 +88,10 @@ class memmap(ndarray):
self._mmap.flush()
def close(self):
- self._mmap.close()
+ if (self.base is self._mmap):
+ self._mmap.close()
def __del__(self):
if self._mmap is not None:
self._mmap.flush()
- del self._mmap
+ self.close()