[issue37185] use os.memfd_create in multiprocessing.shared_memory?

Davin Potts report at bugs.python.org
Mon Sep 9 08:34:09 EDT 2019


Davin Potts <python at discontinuity.net> added the comment:

Unless I am missing something, memfd_create appears to be specific to the Linux kernel still so we would need to replicate its behavior on all of the other unix systems.

To your point, but quoting from the docs, "separate invocations of memfd_create with the same name will not return descriptors for the same region of memory".  If it is possible to use the anonymous shared memory created via memfd_create in another process (which is arguably the primary motivation / use case for multiprocessing.shared_memory), we would need to replicate the unique way of referencing a shared memory segment when trying to attach to it from other processes.

To permit resource management of a shared memory segment (in the sense of ensuring the shared memory segment is always unlinked at the end), the multiprocessing.managers.SharedMemoryManager exists.  Because destroying a shared memory segment at exit is not always desirable, the SharedMemoryManager provides additional control over when it is appropriate to unlink a shared memory segment.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue37185>
_______________________________________


More information about the Python-bugs-list mailing list