pypck.timeout_retry

Base classes for handling reoccurent tasks.

class pypck.timeout_retry.TimeoutRetryHandler(task_registry: TaskRegistry, num_tries: int = 3, timeout: float = 3.5)

Manage timeout and retry logic for an LCN request.

activate() → None

Schedule the next activation.

async async_activate() → None

Clean start of next timeout_loop.

async cancel() → None

Must be called when a response (requested or not) is received.

async done() → None

Signal the completion of the TimeoutRetryHandler.

is_active() → bool

Check whether the request logic is active.

async on_timeout(failed: bool = False) → None

Is called on timeout of TimeoutRetryHandler.

set_timeout(timeout: int) → None

Set the timeout in seconds.

set_timeout_callback(timeout_callback: Any, *timeout_args: Any, **timeout_kwargs: Any) → None

Timeout_callback function is called, if timeout expires.

Function has to take one argument: Returns failed state (True if failed)

async timeout_loop() → None

Timeout / retry loop.