[Python-ideas] Adding shm_open to mmap?

shibturn shibturn at gmail.com
Wed Feb 15 18:43:25 CET 2012


On 15/02/2012 5:02pm, Antoine Pitrou wrote:
> On Wed, 15 Feb 2012 13:25:14 +0000
> Can you elaborate? I would think the general use case is to keep an
> mmap alive as long as you need it, so I don't understand why someone
> would destroy an mmap just after sending it to another process.

A process which creates an mmap may want to transfer ownership of the 
mmap to another process along a pipeline.  For example:

1) Process A creates an mmap
2) Process A does some work on mmap
3) Process A puts mmap on a queue.
4) mmap gets garbage collected in process A.
5) Process B gets mmap from queue.
...

With refcounting the mmap will be destroyed at step 4.  With 
shm_open/shm_unlink, it would be Process B's responsibility to unlink 
the file.

This is the scenario which Sturla Molden was concerned with, although he 
hadn't thought through the premature disposal issue.

sbt

P.S. I have posted a possible implementation of shm_open/shm_unlink for 
Windows at

 
http://mail.python.org/pipermail/concurrency-sig/2012-February/000058.html




More information about the Python-ideas mailing list