Skip to content

yuyo.timeouts#

Classes used for handling timing out components and reaction handlers.

AbstractTimeout #

Bases: ABC

Abstract interface used to manage timing out a modals and components.

has_expired abstractmethod property #

has_expired

Whether this has timed-out.

increment_uses abstractmethod #

increment_uses()

Add a use to this.

Returns:

  • bool

    Whether this has now timed-out.

NeverTimeout #

Bases: AbstractTimeout

Timeout implementation which never expires.

SlidingTimeout #

Bases: AbstractTimeout

Timeout strategy which resets every use.

This implementation times out if timeout passes since the last call or when max_uses is reached.

__init__ #

__init__(timeout, /, *, max_uses=1)

Initialise a sliding timeout.

Parameters:

  • timeout (Union[timedelta, int, float]) –

    How long this should wait between calls before timing-out.

  • max_uses (int, default: 1 ) –

    The maximum amount of uses this allows.

    Setting this to -1 marks it as unlimited.

StaticTimeout #

Bases: AbstractTimeout

Timeout at a specific time.

This implementation times out when timeout_at is reached or when max_uses is reached.

__init__ #

__init__(timeout_at, /, *, max_uses=1)

Initialise a static timeout.

Parameters:

  • timeout_at (datetime) –

    When this should time out.

  • max_uses (int, default: 1 ) –

    The maximum amount of uses this allows.

    Setting this to -1 marks it as unlimited.