mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-04-26 16:46:23 +00:00
Fix lock being unexpectedly reset on close (#218)
* Implement a backoff for legacy devices * do not clear self.query_lock at close() * revert backoff
This commit is contained in:
parent
3cf549e32e
commit
33bc38b57f
@ -28,7 +28,6 @@ class TPLinkSmartHomeProtocol:
|
||||
INITIALIZATION_VECTOR = 171
|
||||
DEFAULT_PORT = 9999
|
||||
DEFAULT_TIMEOUT = 5
|
||||
|
||||
BLOCK_SIZE = 4
|
||||
|
||||
def __init__(self, host: str) -> None:
|
||||
@ -111,7 +110,7 @@ class TPLinkSmartHomeProtocol:
|
||||
async def close(self):
|
||||
"""Close the connection."""
|
||||
writer = self.writer
|
||||
self._reset()
|
||||
self.reader = self.writer = None
|
||||
if writer:
|
||||
writer.close()
|
||||
with contextlib.suppress(Exception):
|
||||
@ -119,10 +118,7 @@ class TPLinkSmartHomeProtocol:
|
||||
|
||||
def _reset(self):
|
||||
"""Clear any varibles that should not survive between loops."""
|
||||
self.writer = None
|
||||
self.reader = None
|
||||
self.query_lock = None
|
||||
self.loop = None
|
||||
self.reader = self.writer = self.loop = self.query_lock = None
|
||||
|
||||
async def _query(self, request: str, retry_count: int, timeout: int) -> Dict:
|
||||
"""Try to query a device."""
|
||||
|
Loading…
x
Reference in New Issue
Block a user