poetry: add aiohttp_retry to handle synapse 429s

This commit is contained in:
Gaël Goinvic committed 2024-11-22 13:17:30 +01:00
1 parent 541449210e
commit e6c73bbee3
3 files changed
+25 -2

No files matched your search

Generated
+15 -1
View File
@@ -122,6 +122,20 @@ yarl = ">=1.17.0,<2.0"
[package.extras]
speedups = ["Brotli", "aiodns (>=3.2.0)", "brotlicffi"]
[[package]]
name = "aiohttp-retry"
version = "2.9.1"
description = "Simple retry client for aiohttp"
optional = false
python-versions = ">=3.7"
files = [
{file = "aiohttp_retry-2.9.1-py3-none-any.whl", hash = "sha256:66d2759d1921838256a05a3f80ad7e724936f083e35be5abb5e16eed6be6dc54"},
{file = "aiohttp_retry-2.9.1.tar.gz", hash = "sha256:8eb75e904ed4ee5c2ec242fefe85bf04240f685391c4879d8f541d6028ff01f1"},
]
[package.dependencies]
aiohttp = "*"
[[package]]
name = "aiomultiprocess"
version = "0.9.1"
@@ -3241,4 +3255,4 @@ type = ["pytest-mypy"]
[metadata]
lock-version = "2.0"
python-versions = ">=3.12,<4.0"
content-hash = "3d3667f621facbd4b12fac21ac2514d0bff618901d661a6b764159c92eaf8b90"
content-hash = "e6ea7d52edcf7fe8f6a2d71c944a9bfb0f220b9f237e6764bd14886fe81c8440"
+1
View File
@@ -10,6 +10,7 @@ package-mode = false
[tool.poetry.dependencies]
python = ">=3.12,<4.0"
aiohttp-retry = "^2.9.1"
[tool.poetry.group.dev.dependencies]
pyhelm3 = "^0.4.0"
+9 -1
View File
@@ -11,6 +11,14 @@ from typing import Any
from urllib.parse import urlparse
import aiohttp
from aiohttp_retry import ExponentialRetry, RetryClient
retry_options = ExponentialRetry(
attempts=30,
statuses=[429],
retry_all_server_errors=False,
exceptions=[aiohttp.client_exceptions.ClientResponseError],
)
@dataclass
@@ -54,7 +62,7 @@ async def aiottp_get_json(url: str, ssl_context: SSLContext) -> Any:
async with aiohttp.ClientSession(
connector=aiohttp.TCPConnector(ssl=ssl_context), raise_for_status=True
) as session, session.get(
) as session, RetryClient(session, retry_options=retry_options) as retry, retry.get(
url.replace(host, "127.0.0.1"),
headers={"Host": host},
server_hostname=host,