clockblocks.scheduler.TimingBackend

class clockblocks.scheduler.TimingBackend[source]

Bases: object

The scheduler’s pluggable source of “now” and of the condition it uses for waiting.

The scheduler (and therefore an entire clock family) has exactly one timed sleep — the run loop’s wait on _queue_change_condition (see Scheduler.run() STEP 1c). That condition is sourced from the TimingBackend passed in the constructor, and defaults to a regular condition on a plain lock. Similarly, all timing reads within the scheduler run through timing_backend.now(). The backend therefore defines both how time is perceived and how the scheduler waits.

See CompressedTime for a backend used to run fast deterministic tests.

Methods

get_sleep_condition()

A fresh condition variable for the scheduler's run loop to wait on.

now()

The backend's current time, in seconds.

now() → float[source]

The backend’s current time, in seconds. Only differences between readings are meaningful; the origin is arbitrary.

get_sleep_condition() → Condition[source]

A fresh condition variable for the scheduler’s run loop to wait on. Timeouts passed to its wait() are interpreted in the same units now() returns.