jinks_core.scheduler

Methods for the standard mode schedules.

Classes

Scheduler(*args)

Continuous method running scheduler.

Exceptions

JinksRefreshParsingError

Refresh parsing error.

JinksSchedulingError

Scheduling error.

exception jinks_core.scheduler.JinksSchedulingError

Bases: JinksError

Scheduling error.

exception jinks_core.scheduler.JinksRefreshParsingError

Bases: JinksError

Refresh parsing error.

class jinks_core.scheduler.Scheduler(*args)

Bases: object

Continuous method running scheduler.

separation_time: timedelta = datetime.timedelta(seconds=20)
__init__(*args)
timedeltas: tuple[timedelta, ...]
callables: tuple[Callable, ...]
static parse_interval(interval_str)

Parse interval string like ‘1d’, ‘2h’, ‘30m’, ’45s’ into a timedelta object.

Parameters:

interval_str (str) – String in format like ‘1d’, ‘2h’, ‘30m’, ’45s’

Return type:

timedelta

Returns:

Timedelta based on the input string

Raises:

ValueError – If interval format is invalid:

run()

Run synchronous function scheduler.

Parameters:

args – Iterable of tuple arguments combining a datetime.timedelta and Callable. First must have a higher timedelta than the second and so on.

Return type:

None

classmethod validate_intervals(deltas)

Validate that intervals meet requirements.

  • First interval is higher than second interval and so on.

  • All interval must be at least fractions of 2 of each other, i.e. (1h, 10m, 5m, 1m) or (5m, 1m, 30s) but not (10m, 8m)

  • All intervals must allow at least 20 seconds for execution, so no datetime.timedelta below 20s.

Parameters:

deltas (tuple[timedelta, ...]) – tuple of provided datetime.timedelta

Return type:

None

static next_interval(current_timestamp, intervals)

Get the next interval and provide which index was chosen.

Return type:

tuple[int, datetime]

static previous_interval(current_timestamp, intervals)

Get the previous interval and provide which index was chosen.

Return type:

tuple[int, datetime]

static sleep_until(date)

Sleep until datetime.

Return type:

None

static on_interval(current_timestamp, interval)

Check if current time is exactly on the interval.

Return type:

bool