class documentation

class SleepDriver: (source)

View In Hierarchy

Instantiate a SleepDriver with no arguments to get one that sleeps using time.sleep and gets the current time with time.time.

For testing, you can supply those parameters, but for most test cases, you should probably prefer a fritter.drivers.memory.MemoryDriver.

Method block While any active timer is scheduled with reschedule, sleep until the desired time specified by that call, call the work that was scheduled, and repeat.
Method now Implementation of TimeDriver.now
Method reschedule Implementation of TimeDriver.reschedule
Method unschedule Implementation of TimeDriver.unschedule
Instance Variable sleep The time.sleep-like callable that this driver will use to sleep for a given number of seconds.
Instance Variable time The time.time-like callable that this driver will use to get the current time.
Instance Variable _work Undocumented
def block(self, timeout: float = inf) -> int: (source)

While any active timer is scheduled with reschedule, sleep until the desired time specified by that call, call the work that was scheduled, and repeat.

Parameters
timeout:floatif specified, the maximum, total number of seconds to sleep before unblocking, even if work remains to be done.
Returns
intUndocumented
Note
When this driver runs out of work to do, it will return immediately, even if it has not yet slept for total seconds. An idle SleepDriver will return immediately without ever blocking.
def now(self) -> float: (source)

Implementation of TimeDriver.now

def reschedule(self, desiredTime: float, work: Callable[[], None]): (source)

Implementation of TimeDriver.reschedule

def unschedule(self): (source)

Implementation of TimeDriver.unschedule

The time.sleep-like callable that this driver will use to sleep for a given number of seconds.

The time.time-like callable that this driver will use to get the current time.

Undocumented