Add retry_utils, update docstrings, add tests

This commit is contained in:
2025-05-01 00:35:36 -04:00
parent b9529d85ce
commit 4b1a9ef718
10 changed files with 205 additions and 52 deletions

16
falyx/retry_utils.py Normal file
View File

@ -0,0 +1,16 @@
from falyx.action import Action, BaseAction
from falyx.hook_manager import HookType
from falyx.retry import RetryHandler, RetryPolicy
def enable_retries_recursively(action: BaseAction, policy: RetryPolicy | None):
if not policy:
policy = RetryPolicy(enabled=True)
if isinstance(action, Action):
action.retry_policy = policy
action.retry_policy.enabled = True
action.hooks.register(HookType.ON_ERROR, RetryHandler(policy).retry_on_error)
if hasattr(action, "actions"):
for sub in action.actions:
enable_retries_recursively(sub, policy)