diff --git a/src/calibre/utils/shm.py b/src/calibre/utils/shm.py index abb083c75a..6857b18a44 100644 --- a/src/calibre/utils/shm.py +++ b/src/calibre/utils/shm.py @@ -132,6 +132,15 @@ class SharedMemory: self._size = size + @property + def memory_address(self) -> int: + import ctypes + obj = ctypes.py_object(self.mmap) + address = ctypes.c_void_p() + length = ctypes.c_ssize_t() + ctypes.pythonapi.PyObject_AsReadBuffer(obj, ctypes.byref(address), ctypes.byref(length)) + return address.value + def read(self, sz: int = 0) -> bytes: if sz <= 0: sz = self.size