akkudoktoreos.server.rest.tasks.repeat_every

akkudoktoreos.server.rest.tasks.repeat_every(*, seconds: float, wait_first: float | None = None, logger: Logger | None = None, raise_exceptions: bool = False, max_repetitions: int | None = None, on_complete: Callable[[], None] | Callable[[], Coroutine[Any, Any, None]] | None = None, on_exception: Callable[[Exception], None] | Callable[[Exception], Coroutine[Any, Any, None]] | None = None) Callable[[Callable[[], None] | Callable[[], Coroutine[Any, Any, None]]], Callable[[], Coroutine[Any, Any, None]]]

A decorator that modifies a function so it is periodically re-executed after its first call.

The function it decorates should accept no arguments and return nothing. If necessary, this can be accomplished by using functools.partial or otherwise wrapping the target function prior to decoration.

Parameters

seconds: float

The number of seconds to wait between repeated calls

wait_first: float (default None)

If not None, the function will wait for the given duration before the first call

max_repetitions: Optional[int] (default None)

The maximum number of times to call the repeated function. If None, the function is repeated forever.

on_complete: Optional[Callable[[], None]] (default None)

A function to call after the final repetition of the decorated function.

on_exception: Optional[Callable[[Exception], None]] (default None)

A function to call when an exception is raised by the decorated function.