add a close handler to release internal resources
This commit is contained in:
@@ -105,7 +105,16 @@ class Modbus():
|
||||
self.req_pend = False
|
||||
self.tim = None
|
||||
|
||||
def close(self):
|
||||
"""free the queue and the callback handler"""
|
||||
logging.debug('Modbus close:')
|
||||
self.rsp_handler = None
|
||||
self.snd_handler = None
|
||||
while not self.que.empty:
|
||||
self.que.get_nowait()
|
||||
|
||||
def __del__(self):
|
||||
"""log statistics on the deleting of a MODBUS instance"""
|
||||
logging.debug(f'Modbus __del__:\n {self.counter}')
|
||||
|
||||
def build_msg(self, addr: int, func: int, reg: int, val: int,
|
||||
|
||||
Reference in New Issue
Block a user