implement close() to release cercular references

This commit is contained in:
Stefan Allius
2023-10-03 00:46:45 +02:00
parent 00f1fe01bf
commit 056e182f64

View File

@@ -100,6 +100,14 @@ class Message(metaclass=IterRegistry):
''' '''
Our puplic methods Our puplic methods
''' '''
def close(self) -> None:
logger.debug(f'in Message.close()')
# we have refernces to methods of this class in self.switch
# so we have to erase self.switch, otherwise this instance can't be
# deallocated by the garbage collector ==> we get a memory leak
del self.switch
def read(self) -> None: def read(self) -> None:
self._read() self._read()