- Add comprehensive module docstrings across the codebase for better clarity and documentation. - Refactor Enum classes (e.g., FileType, ConfirmType) to use `_missing_` for built-in coercion from strings. - Add `encoding` attribute to `LoadFileAction`, `SaveFileAction`, and `SelectFileAction` for more flexible file handling. - Enable lazy file loading by default in `SelectFileAction` to improve performance. - Simplify bottom bar toggle behavior: all toggles now use `ctrl+<key>`, eliminating the need for key conflict checks with Falyx commands. - Add `ignore_in_history` attribute to `Command` to refine how `ExecutionRegistry` identifies the last valid result. - Improve History command output: now includes tracebacks when displaying exceptions.
29 lines
1.1 KiB
Python
29 lines
1.1 KiB
Python
# Falyx CLI Framework — (c) 2025 rtj.dev LLC — MIT Licensed
|
|
"""
|
|
Utilities for enabling retry behavior across Falyx actions.
|
|
|
|
This module provides a helper to recursively apply a `RetryPolicy` to an action and its
|
|
nested children (e.g. `ChainedAction`, `ActionGroup`), and register the appropriate
|
|
`RetryHandler` to hook into error handling.
|
|
|
|
Includes:
|
|
- `enable_retries_recursively`: Attaches a retry policy and error hook to all eligible actions.
|
|
"""
|
|
from falyx.action.action import Action
|
|
from falyx.action.base_action import 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)
|