API

Module contents

Run a python script or function only once in a given time frame.

class once_only.Once(timedelta: timedelta, file: Optional[Path] = None)[source]

Bases: object

Class for time keeping, enabling you to run functions only once in a given time span.

check_ready() bool[source]

Check if the last execution was longer ago than the timedelta.

Returns True if the last execution was longer ago, False otherwise. Does not record a new execution.

check_ready_trigger() bool[source]

Check if the last execution was longer ago than the timedelta, and record a new execution.

If the last execution was longer ago than the timedelta, return True and records a new execution now. Otherwise, returns False.