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

feat(agents-api): Add retry policies to temporal workflows/activities #551

Merged
merged 12 commits into from
Oct 5, 2024
Prev Previous commit
Next Next commit
feat(agents-api): Add more common exceptions to non-retryable set
Signed-off-by: Diwank Singh Tomer <[email protected]>
  • Loading branch information
creatorrr committed Oct 2, 2024
commit ccd01db3eaa0867db894070d3957443b5cde2c4b
53 changes: 43 additions & 10 deletions agents-api/agents_api/common/retry_policies.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,65 @@

from temporalio.common import RetryPolicy
from ..env import debug, testing

DEFAULT_RETRY_POLICY = RetryPolicy(
initial_interval=timedelta(seconds=1),
backoff_coefficient=2,
maximum_attempts=2 if debug or testing else 25,
maximum_interval=timedelta(seconds=10) if debug or testing else timedelta(seconds=300),
maximum_interval=timedelta(seconds=10)
if debug or testing
else timedelta(seconds=300),
non_retryable_error_types=[
# Temporal-specific errors
"WorkflowExecutionAlreadyStarted",
"temporalio.exceptions.TerminalFailure",
"temporalio.exceptions.CanceledError",
#
# Built-in Python exceptions
"TypeError",
"AssertionError",
"HTTPException",
"SyntaxError",
"ValueError",
HamadaSalhab marked this conversation as resolved.
Show resolved Hide resolved
"ZeroDivisionError",
"IndexError",
"AttributeError",
"LookupError",
"BufferError",
"ArithmeticError",
"KeyError",
"NameError",
"NotImplementedError",
"RecursionError",
"RuntimeError",
"StopIteration",
"StopAsyncIteration",
"IndentationError",
"TabError",
#
# Unicode-related errors
"UnicodeError",
"UnicodeEncodeError",
"UnicodeDecodeError",
"UnicodeTranslateError",
#
# HTTP and API-related errors
"HTTPException",
"fastapi.exceptions.HTTPException",
"fastapi.exceptions.RequestValidationError",
"httpx.RequestError",
"httpx.HTTPStatusError",
#
# Asynchronous programming errors
"asyncio.CancelledError",
"asyncio.InvalidStateError",
"GeneratorExit",
#
# Third-party library exceptions
"jinja2.exceptions.TemplateSyntaxError",
"jinja2.exceptions.TemplateNotFound",
"jsonschema.exceptions.ValidationError",
"pydantic.ValidationError",
"asyncio.CancelledError",
"asyncio.InvalidStateError",
"requests.exceptions.InvalidURL",
"requests.exceptions.MissingSchema",
"temporalio.exceptions.TerminalFailure",
"temporalio.exceptions.CanceledError",
"fastapi.exceptions.HTTPException",
"fastapi.exceptions.RequestValidationError",
"httpx.RequestError",
"httpx.HTTPStatusError",
],
)
Loading