Josh Rosenberg <shadowranger+pyt...@gmail.com> added the comment:

Why would it "cause an issue if the file is closed before accessing the mmapped 
region"? As shown in your own link, the constructor performs the mmap call 
immediately after the descriptor is duplicated, with the GIL held; any race 
condition that could close the file before the mmap occurs could equally well 
close it before the descriptor is duplicated.

The possible issues aren't tied to accessing the memory (once the mapping has 
been performed, the file descriptor can be safely closed in general), but 
rather, to the size and resize methods of mmap objects (the former using the fd 
to fstat the file, the latter using it to ftruncate the file). As long as you 
don't use size/resize, nothing else depends on the file descriptor after 
construction has completed. The size method in particular seems like a strange 
wart on the API; it returns the total file size, not the size of the mapping 
(len(mapping) gets the size of the actual mapping).

----------
nosy: +josh.r

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue34321>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to