Job¶
- class scheduler.threading.job.Job(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, weight: float = 1)[source]¶
Bases:
BaseJob[Callable[[…],None]]Jobclass bundling time and callback function methods.- Parameters:
- job_typeJobType
Indicator which defines which calculations has to be used.
- timingTimingWeekly
Desired execution time(s).
- handleCallable[…, None]
Handle to a callback function.
- argstuple[Any]
Positional argument payload for the function handle within a
Job.- kwargsOptional[dict[str, Any]]
Keyword arguments payload for the function handle within a
Job.- max_attemptsOptional[int]
Number of times the
Jobwill be executed where0 <=> inf. AJobwith no free attempt will be deleted.- tagsOptional[set[str]]
The tags of the
Job.- delayOptional[bool]
Deprecated: If
Truewait with the execution for the next scheduled time.- startOptional[datetime.datetime]
Set the reference datetime.datetime stamp the
Jobwill be scheduled against. Default value is datetime.datetime.now().- stopOptional[datetime.datetime]
Define a point in time after which a
Jobwill be stopped and deleted.- skip_missingOptional[bool]
If
TrueaJobwill only schedule it’s newest planned execution and drop older ones.- aliasOptional[str]
Overwrites the function handle name in the string representation.
- tzinfoOptional[datetime.tzinfo]
- weightOptional[float]
Relative weight against other
Jobs.
- Returns:
- Job
Instance of a scheduled
Job.
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
Trueif 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
Trueif 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.
Return the weight of the Job instance.
- property args: tuple[Any, ...]¶
Get the positional arguments of the function handle within a Job.
Warning
When running
BaseJobs 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
Trueif the first Job execution will wait for the next scheduled time.- Returns:
- bool
If
Truewait with the execution for the next scheduled time. IfFalsethe 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: T¶
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
BaseJobhas open execution counts and the stop argument is not in the past relative to the next planed execution.- Returns:
- bool
True if the
BaseJobhas execution attempts.
- property kwargs: dict[str, Any]¶
Get the keyword arguments of the function handle within a Job.
Warning
When running
BaseJobs 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
Trueif Job will only schedule it’s newest planned execution.- Returns:
- bool
If
TrueaBaseJobwill 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.
- property type: JobType¶
Return the JobType of the Job instance.
- Returns:
- JobType
JobTypeof theBaseJob.