This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author josh.r
Recipients josh.r, manuels
Date 2018-08-03.20:34:49
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1533328489.47.0.56676864532.issue34321@psf.upfronthosting.co.za>
In-reply-to
Content
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).
History
Date User Action Args
2018-08-03 20:34:49josh.rsetrecipients: + josh.r, manuels
2018-08-03 20:34:49josh.rsetmessageid: <1533328489.47.0.56676864532.issue34321@psf.upfronthosting.co.za>
2018-08-03 20:34:49josh.rlinkissue34321 messages
2018-08-03 20:34:49josh.rcreate