правки в транспорт сообщений + немного мониторинга

This commit is contained in:
mi
2026-07-20 19:33:46 +03:00
parent d1a0f3791d
commit 3b71caf7b3
9 changed files with 644 additions and 4 deletions
@@ -159,7 +159,7 @@ def retry_delay(attempt: int, maximum: int) -> float:
def safely_retryable(exc: Exception) -> bool:
return isinstance(exc, (httpx.ConnectError, httpx.TimeoutException)) or (
return isinstance(exc, (TimeoutError, httpx.ConnectError, httpx.TimeoutException)) or (
isinstance(exc, httpx.HTTPStatusError) and exc.response.status_code in {429, 502, 503, 504}
)
@@ -751,7 +751,10 @@ def create_app(settings: Settings | None = None) -> FastAPI:
),
)
try:
result = await deliver_outbound(request.app, row.id)
result = await asyncio.wait_for(
deliver_outbound(request.app, row.id),
timeout=cfg.bitrix_http_timeout_sec,
)
except Exception as exc:
logger.exception(
"outbound delivery failed",
@@ -1257,7 +1260,10 @@ async def process_outbound(app: FastAPI) -> None:
if not row:
return
try:
await deliver_outbound(app, row.id)
await asyncio.wait_for(
deliver_outbound(app, row.id),
timeout=app.state.settings.bitrix_http_timeout_sec,
)
except Exception as exc:
logger.exception(
"outbound retry failed",
@@ -208,6 +208,7 @@ def test_fingerprint_ignores_signed_query_and_portal_validation():
def test_network_timeouts_are_retryable():
assert safely_retryable(TimeoutError("Delivery operation timed out"))
assert safely_retryable(httpx.ReadTimeout("Bitrix response timed out"))
assert safely_retryable(httpx.ConnectTimeout("Bitrix connection timed out"))