fix timer cleanup

This commit is contained in:
Stefan Allius
2024-06-25 23:13:59 +02:00
parent 26aebbcab8
commit 18f6332784
3 changed files with 5 additions and 5 deletions

View File

@@ -77,13 +77,13 @@ class Talent(Message):
'''
def close(self) -> None:
logging.debug('Talent.close()')
# we have refernces to methods of this class in self.switch
# we have references 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
self.switch.clear()
self.log_lvl.clear()
self.state = State.closed
del self.mb_timer
self.mb_timer.close()
super().close()
def __set_serial_no(self, serial_no: str):

View File

@@ -134,13 +134,13 @@ class SolarmanV5(Message):
'''
def close(self) -> None:
logging.debug('Solarman.close()')
# we have refernces to methods of this class in self.switch
# we have references 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
self.switch.clear()
self.log_lvl.clear()
self.state = State.closed
del self.mb_timer
self.mb_timer.close()
super().close()
def __set_serial_no(self, snr: int):

View File

@@ -30,6 +30,6 @@ class Timer:
logging.debug(f'[{self.id_str}]Timer expired')
self.__timeout_cb(next(self.exp_count))
def __del__(self) -> None:
def close(self) -> None:
self.stop()
self.__timeout_cb = None