aioamazondevices 3.4.0__tar.gz → 3.5.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {aioamazondevices-3.4.0 → aioamazondevices-3.5.0}/PKG-INFO +1 -1
- {aioamazondevices-3.4.0 → aioamazondevices-3.5.0}/pyproject.toml +1 -1
- {aioamazondevices-3.4.0 → aioamazondevices-3.5.0}/src/aioamazondevices/__init__.py +1 -1
- {aioamazondevices-3.4.0 → aioamazondevices-3.5.0}/src/aioamazondevices/api.py +34 -9
- {aioamazondevices-3.4.0 → aioamazondevices-3.5.0}/LICENSE +0 -0
- {aioamazondevices-3.4.0 → aioamazondevices-3.5.0}/README.md +0 -0
- {aioamazondevices-3.4.0 → aioamazondevices-3.5.0}/src/aioamazondevices/const.py +0 -0
- {aioamazondevices-3.4.0 → aioamazondevices-3.5.0}/src/aioamazondevices/exceptions.py +0 -0
- {aioamazondevices-3.4.0 → aioamazondevices-3.5.0}/src/aioamazondevices/py.typed +0 -0
- {aioamazondevices-3.4.0 → aioamazondevices-3.5.0}/src/aioamazondevices/sounds.py +0 -0
- {aioamazondevices-3.4.0 → aioamazondevices-3.5.0}/src/aioamazondevices/utils.py +0 -0
@@ -1,5 +1,6 @@
|
|
1
1
|
"""Support for Amazon devices."""
|
2
2
|
|
3
|
+
import asyncio
|
3
4
|
import base64
|
4
5
|
import hashlib
|
5
6
|
import mimetypes
|
@@ -369,15 +370,39 @@ class AmazonEchoApi:
|
|
369
370
|
self._load_website_cookies() if self._login_stored_data else self._cookies
|
370
371
|
)
|
371
372
|
self.session.cookie_jar.update_cookies(_cookies)
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
373
|
+
|
374
|
+
resp: ClientResponse | None = None
|
375
|
+
for delay in [0, 1, 2, 5, 8, 12, 21]:
|
376
|
+
if delay:
|
377
|
+
_LOGGER.info(
|
378
|
+
"Sleeping for %s seconds before retrying API call to %s", delay, url
|
379
|
+
)
|
380
|
+
await asyncio.sleep(delay)
|
381
|
+
|
382
|
+
try:
|
383
|
+
resp = await self.session.request(
|
384
|
+
method,
|
385
|
+
URL(url, encoded=True),
|
386
|
+
data=input_data if not json_data else orjson.dumps(input_data),
|
387
|
+
headers=headers,
|
388
|
+
)
|
389
|
+
|
390
|
+
except (TimeoutError, ClientConnectorError) as exc:
|
391
|
+
_LOGGER.warning("Connection error to %s: %s", url, repr(exc))
|
392
|
+
raise CannotConnect(f"Connection error during {method}") from exc
|
393
|
+
|
394
|
+
# Retry with a delay only for specific HTTP status
|
395
|
+
# that can benefits of a back-off
|
396
|
+
if resp.status not in [
|
397
|
+
HTTPStatus.INTERNAL_SERVER_ERROR,
|
398
|
+
HTTPStatus.SERVICE_UNAVAILABLE,
|
399
|
+
HTTPStatus.TOO_MANY_REQUESTS,
|
400
|
+
]:
|
401
|
+
break
|
402
|
+
|
403
|
+
if resp is None:
|
404
|
+
_LOGGER.error("No response received from %s", url)
|
405
|
+
raise CannotConnect(f"No response received from {url}")
|
381
406
|
|
382
407
|
if not self._csrf_cookie:
|
383
408
|
self._csrf_cookie = resp.cookies.get(CSRF_COOKIE, Morsel()).value
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|