diff --git a/cyclonedds/core.py b/cyclonedds/core.py index f3f506f4..a13e3c10 100644 --- a/cyclonedds/core.py +++ b/cyclonedds/core.py @@ -187,10 +187,10 @@ def __init__(self, ref: int, listener: "Listener" = None) -> None: self._listener = listener def __del__(self) -> None: - if not hasattr(self, "_ref"): + if not hasattr(self, "_ref") or self._ref not in self._entities: return - self._entities.pop(self._ref, None) + del self._entities[self._ref] self._delete(self._ref) def get_subscriber(self) -> Optional["cyclonedds.sub.Subscriber"]: