Skip to main content

schedule

Schedule for periodic task.

Attributes

AttributeTypeDescription
relativebool = FalseIf set to True the run time will be rounded to the resolution of the interval.

Constructor

Signature

def schedule(
run_every: float | timedelta | None = None,
relative: bool = False,
nowfun: Callable | None = None,
app: Celery | None = None
) - > None

Parameters

NameTypeDescription
run_every`floattimedelta
relativebool = FalseIf True, run time is rounded to the resolution of the interval.
nowfun`CallableNone` = None
app`CeleryNone` = None

Signature

def schedule(
run_every: float | timedelta | None = None,
relative: bool = False,
nowfun: Callable | None = None,
app: Celery | None = None
) - > null

Parameters

NameTypeDescription
run_every`floattimedelta
relativebool = FalseIf True, rounds the run time to the resolution of the interval for consistent alignment.
nowfun`CallableNone` = None
app`CeleryNone` = None

Methods


remaining_estimate()

@classmethod
def remaining_estimate(
last_run_at: datetime
) - > timedelta

Calculates the time remaining until the next scheduled task execution based on the last run time.

Parameters

NameTypeDescription
last_run_atdatetimeThe timestamp representing when the task was last executed.

Returns

TypeDescription
timedeltaThe duration of time left before the task is due to run again.

is_due()

@classmethod
def is_due(
last_run_at: datetime
) - > tuple[bool, datetime]

Return tuple of (is_due, next_time_to_check).

Parameters

NameTypeDescription
last_run_atdatetimeThe timestamp of the previous task execution used to determine the next window.

Returns

TypeDescription
tuple[bool, datetime]A tuple containing a boolean indicating if the task is due, and a float/int representing the seconds to wait before the next check.

seconds()

@classmethod
def seconds() - > int | float

Calculates the total number of seconds in the schedule's interval.

Returns

TypeDescription
`intfloat`

human_seconds()

@classmethod
def human_seconds() - > str

Converts the schedule's interval into a user-friendly string representation.

Returns

TypeDescription
strA human-readable string describing the interval (e.g., '1 minute').