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. Other than at program exit, the thread is only destroyed when job.stop is called or when changing the number of seconds in between calls with job.rate = new_seconds.

Example

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

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

When set, our internal scheduler is destroyed and recreated. This is a thread join and start under the hood.

start() → None[source]

Start calling our regularly-scheduled function

stop(timeout=None) → None[source]

Don’t make any more calls until further notice