S or /

Module talon.cron

from talon import cron

Functions

NameReference
after(timespec: str, cb: collections.abc.Callable[[], None]) -> talon.cron.Job
interval(timespec: str, cb: collections.abc.Callable[[], bool | None], backoff: bool = False) -> talon.cron.Job
cancel(job: talon.cron.Job | None) -> None
timespec_to_seconds(s: str) -> float
seconds_to_timespec(duration: float, precision: int | None = None) -> str

Classes

NameReference
Job

Functions

after§

def after(timespec: str, cb: collections.abc.Callable[[], None]) -> talon.cron.Job

Example

from talon import cron

cron.after("1s", lambda: print("Hello"))

interval§

def interval(timespec: str, cb: collections.abc.Callable[[], bool | None], backoff: bool = False) -> talon.cron.Job

Example

from talon import cron

job = cron.interval("1s", lambda: print("tick"))

cancel§

def cancel(job: talon.cron.Job | None) -> None

Example

from talon import cron

job = cron.after("10s", lambda: print("Hello"))
cron.cancel(job)

timespec_to_seconds§

def timespec_to_seconds(s: str) -> float

Example

from talon import cron

seconds = cron.timespec_to_seconds("250ms")

seconds_to_timespec§

def seconds_to_timespec(duration: float, precision: int | None = None) -> str

Example

from talon import cron

timespec = cron.seconds_to_timespec(0.25)