Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(agents-api): Fix retrying the resource busy errors #834

Merged
merged 2 commits into from
Nov 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 4 additions & 12 deletions agents-api/agents_api/common/exceptions/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import pydantic
import requests
import temporalio.exceptions
from tenacity import RetryError

# 🚫 The "No Second Chances" Club - errors that we won't retry
# Because sometimes, no means no!
Expand Down Expand Up @@ -130,6 +131,9 @@
#
# Database/storage related (when the database needs a nap)
asyncio.TimeoutError,
#
# Tenacity exceptions (retry when retrying goes wrong lol)
RetryError,
)

# HTTP status codes that say "maybe try again later?"
Expand Down Expand Up @@ -176,15 +180,3 @@ def is_retryable_error(error: BaseException) -> bool:
# If we don't know this error, we play it safe and don't retry
# (stranger danger!)
return False

# Check for specific HTTP errors that should be retried
if isinstance(error, fastapi.exceptions.HTTPException):
if error.status_code in RETRYABLE_HTTP_STATUS_CODES:
return True

if isinstance(error, httpx.HTTPStatusError):
if error.response.status_code in RETRYABLE_HTTP_STATUS_CODES:
return True

# If we don't know about the error, we should not retry
return False
Loading