Vinay Sharma <vinay0410sha...@gmail.com> added the comment:

Hi Davin,
Thanks for replying!

As you said I went through the issue, and now understand why segments should 
not be automatically created if they don't exist.

But, after reading that thread I got to know that shared memory is supposed to 
exist even if the process exits, and it can only be freed by unlink, which I 
also believe is an important functionality required by many use cases as you 
mentioned.

But, this is not the behaviour currently.
As soon as the process exists, all the shared memory created is unlinked.

Also, the documentation currently mentions: "shared memory blocks may outlive 
the original process that created them", which is not the case at all.

Currently, the resource_tracker, unlinks the shared memory, by calling unlink 
as specified here:
```
if os.name == 'posix':
    import _multiprocessing
    import _posixshmem

    _CLEANUP_FUNCS.update({
        'semaphore': _multiprocessing.sem_unlink,
        'shared_memory': _posixshmem.shm_unlink,
    })
```

So, is this an expected behaviour, if yes documentation should be updated, and 
if not the code base should be.

I will be happy to submit a patch in both the cases.

PS: I personally believe from my experience that shared memory segments should 
outlive the process, unless specified otherwise. Also, a argument persist=True, 
can be added which can ensure that the shared_memory segment outlives the 
process, and can be used by processes which are spawned later.

----------

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

Reply via email to