mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Code to get the memory address of a SharedMemory object
This commit is contained in:
parent
1fecf2c380
commit
83891ed63e
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user