mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-11-24 18:28:21 +00:00
Improve and document close behavior (#654)
* Close connection on smartprotocol timeout * tweaks
This commit is contained in:
@@ -84,8 +84,8 @@ class SmartProtocol(TPLinkProtocol):
|
||||
raise ex
|
||||
continue
|
||||
except TimeoutException as ex:
|
||||
await self.close()
|
||||
if retry >= retry_count:
|
||||
await self.close()
|
||||
_LOGGER.debug("Giving up on %s after %s retries", self._host, retry)
|
||||
raise ex
|
||||
await asyncio.sleep(self.BACKOFF_SECONDS_AFTER_TIMEOUT)
|
||||
@@ -167,7 +167,12 @@ class SmartProtocol(TPLinkProtocol):
|
||||
raise SmartDeviceException(msg, error_code=error_code)
|
||||
|
||||
async def close(self) -> None:
|
||||
"""Close the protocol."""
|
||||
"""Close the underlying transport.
|
||||
|
||||
Some transports may close the connection, and some may
|
||||
use this as a hint that they need to reconnect, or
|
||||
reauthenticate.
|
||||
"""
|
||||
await self._transport.close()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user