Message414258
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()
``` |
|
Date |
User |
Action |
Args |
2022-03-01 11:39:08 | ronny-rentner | set | recipients:
+ ronny-rentner, paul.moore, tim.golden, zach.ware, steve.dower |
2022-03-01 11:39:08 | ronny-rentner | set | messageid: <1646134748.49.0.513958523413.issue46888@roundup.psfhosted.org> |
2022-03-01 11:39:08 | ronny-rentner | link | issue46888 messages |
2022-03-01 11:39:08 | ronny-rentner | create | |
|