Fix P100 errors on multi-requests (#930)

Fixes an issue reported by @bdraco with the P100 not working in the
latest branch:

`[Errno None] Can not write request body for HOST_REDACTED,
ClientOSError(None, 'Can not write request body for
URL_REDACTED'))`

Issue caused by the number of multi requests going above the default
batch of 5 and the P100 not being able to handle the second multi
request happening immediately as it closes the connection after each
query (See https://github.com/python-kasa/python-kasa/pull/690 for
similar issue). This introduces a small wait time on concurrent requests
once the device has raised a ClientOSError.
This commit is contained in:
Steven B
2024-06-04 20:49:01 +03:00
committed by GitHub
parent 40f2263770
commit 91de5e20ba
3 changed files with 102 additions and 5 deletions

View File

@@ -6,7 +6,6 @@ under compatible GNU GPL3 license.
from __future__ import annotations
import asyncio
import base64
import hashlib
import logging
@@ -74,7 +73,6 @@ class AesTransport(BaseTransport):
}
CONTENT_LENGTH = "Content-Length"
KEY_PAIR_CONTENT_LENGTH = 314
BACKOFF_SECONDS_AFTER_LOGIN_ERROR = 1
def __init__(
self,
@@ -216,7 +214,6 @@ class AesTransport(BaseTransport):
self._default_credentials = get_default_credentials(
DEFAULT_CREDENTIALS["TAPO"]
)
await asyncio.sleep(self.BACKOFF_SECONDS_AFTER_LOGIN_ERROR)
await self.perform_handshake()
await self.try_login(self._get_login_params(self._default_credentials))
_LOGGER.debug(