Is there any way to make SharedMemory
object created in Python persist between processes?
If the following code is invoked in interactive python session:
>>> from multiprocessing import shared_memory
>>> shm = shared_memory.SharedMemory(name='test_smm', size=1000000, create=True)
it creates a file in /dev/shm/
on a Linux machine.
ls /dev/shm/test_smm
/dev/shm/test_smm
But when the python session ends I get the following:
/usr/lib/python3.8/multiprocessing/resource_tracker.py:216: UserWarning: resource_tracker: There appear to be 1 leaked shared_memory objects to clean up at shutdownwarnings.warn('resource_tracker: There appear to be %d
and the test_smm
is gone:
ls /dev/shm/test_smm
ls: cannot access '/dev/shm/test_smm': No such file or directory
So is there any way to make the shared memory object created in python persist across process runs?
Running with Python 3.8