qualia_core.utils.process.SharedMemoryManager module
- class qualia_core.utils.process.SharedMemoryManager.SharedMemoryPersistent(name=None, create=False, size=0)[source]
Bases:
SharedMemory
- class qualia_core.utils.process.SharedMemoryManager.SharedMemoryProxy(token, serializer, manager=None, authkey=None, exposed=None, incref=True, manager_owned=False)[source]
Bases:
BaseProxy
- class qualia_core.utils.process.SharedMemoryManager.SharedMemoryManager(*args, **kwargs)[source]
Bases:
SharedMemoryManager
Provides a SharedMemory factory that creates the object on the remote manager process instead of the current process.
Used to workaround Windows-related issue where a SharedMemory object created in a child process would get destroyed and release the shared memory segment at the same time when the process ends, even though the parent process may still want to access it afterwards.
- SharedMemory(size: int) → SharedMemory[source]
Return a new SharedMemory instance with the specified size in bytes, created and tracked by the manager.
Reference count on remote manager is not decremented to keep reference count above 1 so that SharedMemory object does not get destroyed when child process exits and parent process has not accessed it yet. Otherwise, on Windows, the segment becomes inaccessible.
The returned
SharedMemoryPersistent
is a localshared_memory.SharedMemory
object that connects to the same segment as the remote object. On Windows, this local object has itsSharedMemoryPersistent.close()
method ineffective on Windows in order to prevent deletion of the shared segment when the child process exits.The SharedMemory object is still tracked with track_segment so that
close()
and unlink() get called when the SharedMemoryManager gets destroyed.- Parameters:
size – Size of shared memory segment in bytes