Skip to content

Commit ae55db6

Browse files
committed
avoid accessing self's Python attributes in dealloc
1 parent fdf4edc commit ae55db6

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

cuda_core/cuda/core/experimental/_memory.pyx

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@ class DeviceMemoryResourceAttributes:
585585
# This enables buffer serialization, as buffers can reduce to a pair
586586
# of comprising the memory resource UUID (the key into this registry)
587587
# and the serialized buffer descriptor.
588-
_ipc_registry = {}
588+
cdef object _ipc_registry = weakref.WeakValueDictionary()
589589

590590

591591
cdef class DeviceMemoryResource(MemoryResource):
@@ -759,8 +759,6 @@ cdef class DeviceMemoryResource(MemoryResource):
759759
with nogil:
760760
HANDLE_RETURN(cydriver.cuMemPoolDestroy(self._mempool_handle))
761761
finally:
762-
if self.is_mapped:
763-
self.unregister()
764762
self._dev_id = cydriver.CU_DEVICE_INVALID
765763
self._mempool_handle = NULL
766764
self._attributes = None
@@ -806,13 +804,6 @@ cdef class DeviceMemoryResource(MemoryResource):
806804
self._uuid = uuid
807805
return self
808806

809-
def unregister(self):
810-
"""Unregister this mapped memory resource."""
811-
assert self.is_mapped
812-
if _ipc_registry is not None: # can occur during shutdown catastrophe
813-
with contextlib.suppress(KeyError):
814-
del _ipc_registry[self.uuid]
815-
816807
@property
817808
def uuid(self) -> Optional[uuid.UUID]:
818809
"""

0 commit comments

Comments
 (0)