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

Job class 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 Job will be executed where 0 <=> inf. A Job with no free attempt will be deleted.

tagsOptional[set[str]]

The tags of the Job.

delayOptional[bool]

Deprecated: If True wait with the execution for the next scheduled time.

startOptional[datetime.datetime]

Set the reference datetime.datetime stamp the Job will be scheduled against. Default value is datetime.datetime.now().

stopOptional[datetime.datetime]

Define a point in time after which a Job will be stopped and deleted.

skip_missingOptional[bool]

If True a Job will 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]

Set the timezone of the Scheduler the Job is scheduled in.

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

alias

Get the alias of the Job.

args

Get the positional arguments of the function handle within a Job.

attempts

Get the number of executions for a Job.

datetime

Give the datetime.datetime object for the planed execution.

delay

Deprecated: Return True if the first Job execution will wait for the next scheduled time.

failed_attempts

Get the number of failed executions for a Job.

handle

Get the callback function.

has_attempts_remaining

Check if a Job has remaining attempts.

kwargs

Get the keyword arguments of the function handle within a Job.

max_attempts

Get the execution limit for a Job.

skip_missing

Return True if Job will only schedule it's newest planned execution.

start

Get the timestamp at which the JobTimer starts.

stop

Get the timestamp after which no more executions of the Job should be scheduled.

tags

Get the tags of a Job.

type

Return the JobType of the Job instance.

tzinfo

Get the timezone of the Job's next execution.

weight

Return the weight of the Job instance.

property alias: str | None#

Get the alias of the Job.

Returns:
Optional[str]

Alias of the BaseJob.

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 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. If False 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 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 True if Job will only schedule it’s newest planned execution.

Returns:
bool

If True a BaseJob 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.

property tags: set[str]#

Get the tags of a Job.

Returns:
set[str]

The tags of a BaseJob.

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

JobType of the BaseJob.

property tzinfo: tzinfo | None#

Get the timezone of the Job’s next execution.

Returns:
Optional[datetime.tzinfo]

Timezone of the BaseJobs next execution.

property weight: float#

Return the weight of the Job instance.

Returns:
float

Job weight.