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 ronny-rentner
Recipients paul.moore, ronny-rentner, steve.dower, tim.golden, zach.ware
Date 2022-03-01.11:39:08
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1646134748.49.0.513958523413.issue46888@roundup.psfhosted.org>
In-reply-to
Content
According to https://docs.python.org/3/library/multiprocessing.shared_memory.html#multiprocessing.shared_memory.SharedMemory.close if I call close() on a shared memory, it shall not be destroyed.

Unfortunately this is only true for Linux but not for Windows.

I've tested this in a Windows VM on VirtualBox like this:

```
Python 3.10.2 (tags/v3.10.2:a58ebcc, Jan 17 2022, 14:12:15) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import multiprocessing.shared_memory
>>> creator = multiprocessing.shared_memory.SharedMemory(create=True, name='mymemory', size=10000)
>>> creator.buf[0] = 1
>>> creator.buf[0]
1
>>> # According to  close() is supposed to not destroy 'mymemory' but it does destroy it.
>>> creator.close()
>>>
>>> user = multiprocessing.shared_memory.SharedMemory(name='mymemory')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\multiprocessing\shared_memory.py", line 161, in __init__
    h_map = _winapi.OpenFileMapping(
FileNotFoundError: [WinError 2] The system cannot find the file specified: 'mymemory'
>>> # Shared memory was destroyed by close()
```
History
Date User Action Args
2022-03-01 11:39:08ronny-rentnersetrecipients: + ronny-rentner, paul.moore, tim.golden, zach.ware, steve.dower
2022-03-01 11:39:08ronny-rentnersetmessageid: <1646134748.49.0.513958523413.issue46888@roundup.psfhosted.org>
2022-03-01 11:39:08ronny-rentnerlinkissue46888 messages
2022-03-01 11:39:08ronny-rentnercreate