fix timer cleanup
This commit is contained in:
@@ -77,13 +77,13 @@ class Talent(Message):
|
|||||||
'''
|
'''
|
||||||
def close(self) -> None:
|
def close(self) -> None:
|
||||||
logging.debug('Talent.close()')
|
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
|
# so we have to erase self.switch, otherwise this instance can't be
|
||||||
# deallocated by the garbage collector ==> we get a memory leak
|
# deallocated by the garbage collector ==> we get a memory leak
|
||||||
self.switch.clear()
|
self.switch.clear()
|
||||||
self.log_lvl.clear()
|
self.log_lvl.clear()
|
||||||
self.state = State.closed
|
self.state = State.closed
|
||||||
del self.mb_timer
|
self.mb_timer.close()
|
||||||
super().close()
|
super().close()
|
||||||
|
|
||||||
def __set_serial_no(self, serial_no: str):
|
def __set_serial_no(self, serial_no: str):
|
||||||
|
|||||||
@@ -134,13 +134,13 @@ class SolarmanV5(Message):
|
|||||||
'''
|
'''
|
||||||
def close(self) -> None:
|
def close(self) -> None:
|
||||||
logging.debug('Solarman.close()')
|
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
|
# so we have to erase self.switch, otherwise this instance can't be
|
||||||
# deallocated by the garbage collector ==> we get a memory leak
|
# deallocated by the garbage collector ==> we get a memory leak
|
||||||
self.switch.clear()
|
self.switch.clear()
|
||||||
self.log_lvl.clear()
|
self.log_lvl.clear()
|
||||||
self.state = State.closed
|
self.state = State.closed
|
||||||
del self.mb_timer
|
self.mb_timer.close()
|
||||||
super().close()
|
super().close()
|
||||||
|
|
||||||
def __set_serial_no(self, snr: int):
|
def __set_serial_no(self, snr: int):
|
||||||
|
|||||||
@@ -30,6 +30,6 @@ class Timer:
|
|||||||
logging.debug(f'[{self.id_str}]Timer expired')
|
logging.debug(f'[{self.id_str}]Timer expired')
|
||||||
self.__timeout_cb(next(self.exp_count))
|
self.__timeout_cb(next(self.exp_count))
|
||||||
|
|
||||||
def __del__(self) -> None:
|
def close(self) -> None:
|
||||||
self.stop()
|
self.stop()
|
||||||
self.__timeout_cb = None
|
self.__timeout_cb = None
|
||||||
|
|||||||
Reference in New Issue
Block a user