
    i	                    T    S SK Jr  S SKJrJr  \ " S S\5      5       r " S S5      rg)    )annotations)Protocolruntime_checkablec                  2    \ rS rSrSr        SS jrSrg)RetryPolicy	   aT  
Policy interface to control step retries after failures.

Implementations decide whether to retry and how long to wait before the next
attempt based on elapsed time, number of attempts, and the last error.

See Also:
    - [ConstantDelayRetryPolicy][workflows.retry_policy.ConstantDelayRetryPolicy]
    - [step][workflows.decorators.step]
c                    g)a<  
Decide if another retry should occur and the delay before it.

Args:
    elapsed_time (float): Seconds since the first failure.
    attempts (int): Number of attempts made so far.
    error (Exception): The last exception encountered.

Returns:
    float | None: Seconds to wait before retrying, or `None` to stop.
N selfelapsed_timeattemptserrors       P/home/james-whalen/.local/lib/python3.13/site-packages/workflows/retry_policy.pynextRetryPolicy.next   s        r
   Nr   floatr   intr   	Exceptionreturnzfloat | None)__name__
__module____qualname____firstlineno____doc__r   __static_attributes__r
   r   r   r   r   	   s,    	!-09B	r   r   c                  @    \ rS rSrSrSSS jjr        S	S jrSrg)
ConstantDelayRetryPolicy&   zRetry at a fixed interval up to a maximum number of attempts.

Examples:
    ```python
    @step(retry_policy=ConstantDelayRetryPolicy(delay=5, maximum_attempts=10))
    async def flaky(self, ev: StartEvent) -> StopEvent:
        ...
    ```
c                    Xl         X l        g)z
Initialize the policy.

Args:
    maximum_attempts (int): Maximum consecutive attempts. Defaults to 3.
    delay (float): Seconds to wait between attempts. Defaults to 5.
Nmaximum_attemptsdelay)r   r$   r%   s      r   __init__!ConstantDelayRetryPolicy.__init__1   s     !1
r   c                :    X R                   :  a  gU R                  $ )z?Return the fixed delay while attempts remain; otherwise `None`.Nr#   r   s       r   r   ConstantDelayRetryPolicy.next<   s     ,,,zzr   )r%   r$   N)      )r$   r   r%   r   r   Noner   )r   r   r   r   r   r&   r   r   r
   r   r   r    r    &   s1    	!-09B	r   r    N)
__future__r   typingr   r   r   r    r
   r   r   <module>r/      s2    # . (  8 r   