правки в транспорт сообщений + немного мониторинга
This commit is contained in:
@@ -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"))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user