From b82743a5debc6ec1958afaccdeb388093a6012ed Mon Sep 17 00:00:00 2001 From: "Steven B." <51370195+sdb9696@users.noreply.github.com> Date: Tue, 29 Oct 2024 11:52:53 +0000 Subject: [PATCH] Do not pass None as timeout to http requests (#1203) --- kasa/experimental/sslaestransport.py | 3 --- kasa/httpclient.py | 2 ++ kasa/protocol.py | 4 +++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/kasa/experimental/sslaestransport.py b/kasa/experimental/sslaestransport.py index eddc6698..68420f89 100644 --- a/kasa/experimental/sslaestransport.py +++ b/kasa/experimental/sslaestransport.py @@ -97,9 +97,6 @@ class SslAesTransport(BaseTransport): self._default_credentials: Credentials = get_default_credentials( DEFAULT_CREDENTIALS["TAPOCAMERA"] ) - - if not config.timeout: - config.timeout = self.DEFAULT_TIMEOUT self._http_client: HttpClient = HttpClient(config) self._state = TransportState.HANDSHAKE_REQUIRED diff --git a/kasa/httpclient.py b/kasa/httpclient.py index 9904b17b..6b8e234c 100644 --- a/kasa/httpclient.py +++ b/kasa/httpclient.py @@ -89,6 +89,8 @@ class HttpClient: self._last_url = url self.client.cookie_jar.clear() return_json = bool(json) + if self._config.timeout is None: + _LOGGER.warning("Request timeout is set to None.") client_timeout = aiohttp.ClientTimeout(total=self._config.timeout) # If json is not a dict send as data. diff --git a/kasa/protocol.py b/kasa/protocol.py index 1107fa1d..140e9c41 100755 --- a/kasa/protocol.py +++ b/kasa/protocol.py @@ -91,7 +91,9 @@ class BaseTransport(ABC): self._port = config.port_override or self.default_port self._credentials = config.credentials self._credentials_hash = config.credentials_hash - self._timeout = config.timeout or self.DEFAULT_TIMEOUT + if not config.timeout: + config.timeout = self.DEFAULT_TIMEOUT + self._timeout = config.timeout @property @abstractmethod