recurring package

Module contents

Simple library for running a callable every N seconds

job(callable, seconds) will call callable every seconds seconds in a dedicated thread that is destroyed on program exit, or on calling job.terminate.

Attempting to start or modify the rate of a job that has been terminated will raise a RuntimeError

Example

import recurring j = recurring.job(some_callable, some_seconds) j.start() # … j.rate = some_new_seconds # … j.stop() # … j.start() # … j.terminate()

class recurring.job(func: Callable, rate: int) → None[source]

Bases: object

A job is something that is called repeatedly and the time to wait in between calls.

rate

int – seconds in between calls

start() → None[source]

Start calling our regularly-scheduled function

stop() → None[source]

Don’t make any more calls until further notice

terminate() → None[source]

Permanently stop making any more calls

After this method has been called, attempts to start or change the rate of this job will raise a RuntimeError