BaseJob#
- class scheduler.base.job.BaseJob(job_type: JobType, timing: list[datetime.timedelta] | list[datetime.time] | list[scheduler.trigger.core.Weekday], handle: Callable[[...], None], *, args: tuple[Any] | None = None, kwargs: dict[str, Any] | None = None, max_attempts: int = 0, tags: set[str] | None = None, delay: bool = True, start: datetime | None = None, stop: datetime | None = None, skip_missing: bool = False, alias: str | None = None, tzinfo: tzinfo | None = None)[source]#
Bases:
ABC
Abstract definition basic interface for a job class.
Methods
__init__
(job_type, timing, handle, *[, ...])timedelta
([dt_stamp])Get the datetime.timedelta until the next execution of this Job.
Attributes
Get the alias of the Job.
Get the positional arguments of the function handle within a Job.
Get the number of executions for a Job.
Give the datetime.datetime object for the planed execution.
Deprecated: Return
True
if the first Job execution will wait for the next scheduled time.Get the number of failed executions for a Job.
Get the callback function.
Check if a Job has remaining attempts.
Get the keyword arguments of the function handle within a Job.
Get the execution limit for a Job.
Return
True
if Job will only schedule it's newest planned execution.Get the timestamp at which the JobTimer starts.
Get the timestamp after which no more executions of the Job should be scheduled.
Get the tags of a Job.
Return the JobType of the Job instance.
Get the timezone of the Job's next execution.
- property args: tuple[Any, ...]#
Get the positional arguments of the function handle within a Job.
Warning
When running
BaseJob
s in parallel threads, be sure to implement possible side effects of parameter accessing in a thread safe manner.- Returns:
- tuple[Any]
The payload arguments to pass to the function handle within a
BaseJob
.
- property attempts: int#
Get the number of executions for a Job.
- Returns:
- int
Execution attempts.
- property datetime: datetime#
Give the datetime.datetime object for the planed execution.
- Returns:
- datetime.datetime
Execution datetime.datetime stamp.
- property delay: bool#
Deprecated: Return
True
if the first Job execution will wait for the next scheduled time.- Returns:
- bool
If
True
wait with the execution for the next scheduled time. IfFalse
the first execution will target the time of Job.start.
- property failed_attempts: int#
Get the number of failed executions for a Job.
- Returns:
- int
Failed execution attempts.
- property handle: Callable[[...], None]#
Get the callback function.
- Returns:
- handle
Callback function.
- property has_attempts_remaining: bool#
Check if a Job has remaining attempts.
This function will return True if the
BaseJob
has open execution counts and the stop argument is not in the past relative to the next planed execution.- Returns:
- bool
True if the
BaseJob
has execution attempts.
- property kwargs: dict[str, Any]#
Get the keyword arguments of the function handle within a Job.
Warning
When running
BaseJob
s in parallel threads, be sure to implement possible side effects of parameter accessing in a thread safe manner.- Returns:
- dict[str, Any]
The payload arguments to pass to the function handle within a
BaseJob
.
- property max_attempts: int#
Get the execution limit for a Job.
- Returns:
- int
Max execution attempts.
- property skip_missing: bool#
Return
True
if Job will only schedule it’s newest planned execution.- Returns:
- bool
If
True
aBaseJob
will only schedule it’s newest planned execution and drop older ones.
- property start: datetime | None#
Get the timestamp at which the JobTimer starts.
- Returns:
- Optional[datetime.datetime]
The start datetime stamp.
- property stop: datetime | None#
Get the timestamp after which no more executions of the Job should be scheduled.
- Returns:
- Optional[datetime.datetime]
The stop datetime stamp.
- timedelta(dt_stamp: datetime | None = None) timedelta [source]#
Get the datetime.timedelta until the next execution of this Job.
- Parameters:
- dt_stampOptional[datetime.datetime]
Time to be compared with the planned execution time to determine the time difference.
- Returns:
- timedelta
datetime.timedelta to the next execution.