On 1/31/07, Travis Oliphant <oliphant@ee.byu.edu> wrote:
Fernando Perez wrote:
I don't know. If you have other things pointing to it, should you really close it?
Well, it's like a file: you can close it because you've decided it's time to close it, and I think it's better that other references get an exception if they try to write to it when they shouldn't: In [2]: file1 = open('foo','w') In [3]: file1.write('Some text') In [4]: file2 = file1 In [5]: file1.close() In [6]: file2.write("I'm not the original owner but I'll try to write anyway") --------------------------------------------------------------------------- exceptions.ValueError Traceback (most recent call last) /home/fperez/<ipython console> ValueError: I/O operation on closed file This seems like the right API to me.
At any rate you have access to the mmap file through the _mmap attribute. So, you can always do
self._mmap.close()
I don't like an API that encourages access to internal semi-private members, and it seems to me that closing the object is a reasonably top-level operation whose impmlementation details (in this case the existence and name of the _mmap member) should be encapsulated out. Cheers, f