Close connection properly on error
This commit is contained in:
committed by
rospogrigio
parent
2565074c9c
commit
f971646333
@@ -336,11 +336,13 @@ class TuyaProtocol(asyncio.Protocol):
|
||||
def close(self):
|
||||
"""Close connection and abort all outstanding listeners."""
|
||||
if self.transport is not None:
|
||||
self.dispatcher.abort()
|
||||
self.heartbeater.cancel()
|
||||
transport = self.transport
|
||||
self.transport = None
|
||||
transport.close()
|
||||
if self.dispatcher is not None:
|
||||
self.dispatcher.abort()
|
||||
if self.heartbeater is not None:
|
||||
self.heartbeater.cancel()
|
||||
|
||||
async def exchange(self, command, dps=None):
|
||||
"""Send and receive a message, returning response from device."""
|
||||
|
Reference in New Issue
Block a user