8000 Do not pass None as timeout to http requests by sdb9696 · Pull Request #1203 · python-kasa/python-kasa · GitHub
[go: up one dir, main page]

Skip to content

Do not pass None as timeout to http requests #1203

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions kasa/experimental/sslaestransport.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,6 @@ def __init__(
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
Expand Down
2 changes: 2 additions & 0 deletions kasa/httpclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@
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.")

Check warning on line 93 in kasa/httpclient.py

View check run for this annotation

Codecov / codecov/patch

kasa/httpclient.py#L93

Added line #L93 was not covered by tests
client_timeout = aiohttp.ClientTimeout(total=self._config.timeout)

# If json is not a dict send as data.
Expand Down
4 changes: 3 additions & 1 deletion kasa/protocol.py
6B85
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ def __init__(
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
Expand Down
Loading
0