schedule
Schedule for periodic task.
Attributes
| Attribute | Type | Description |
|---|---|---|
| relative | bool = False | If 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
| Name | Type | Description |
|---|---|---|
| run_every | `float | timedelta |
| relative | bool = False | If True, run time is rounded to the resolution of the interval. |
| nowfun | `Callable | None` = None |
| app | `Celery | None` = None |
Signature
def schedule(
run_every: float | timedelta | None = None,
relative: bool = False,
nowfun: Callable | None = None,
app: Celery | None = None
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| run_every | `float | timedelta |
| relative | bool = False | If True, rounds the run time to the resolution of the interval for consistent alignment. |
| nowfun | `Callable | None` = None |
| app | `Celery | None` = 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
| Name | Type | Description |
|---|---|---|
| last_run_at | datetime | The timestamp representing when the task was last executed. |
Returns
| Type | Description |
|---|---|
timedelta | The 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
| Name | Type | Description |
|---|---|---|
| last_run_at | datetime | The timestamp of the previous task execution used to determine the next window. |
Returns
| Type | Description |
|---|---|
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
| Type | Description |
|---|---|
| `int | float` |
human_seconds()
@classmethod
def human_seconds() - > str
Converts the schedule's interval into a user-friendly string representation.
Returns
| Type | Description |
|---|---|
str | A human-readable string describing the interval (e.g., '1 minute'). |