Skip to content

ppqueue.Job

Represents a job returned by a Queue.

Attributes

callback_result class-attribute instance-attribute

callback_result: str | None = field(
    default=None, init=False
)

Result of the callback for this job.

cancelled class-attribute instance-attribute

cancelled: bool = field(default=False, init=False)

Did this job timeout or was it cancelled?

error class-attribute instance-attribute

error: str | None = field(default=None, init=False)

Exception text for this job, if an error occurred.

finish_timestamp class-attribute instance-attribute

finish_timestamp: float | None = field(
    default=None, init=False
)

Unix timestamp of when this job finished.

idx class-attribute instance-attribute

idx: int | None = field(default=None, init=False)

The ID of this job.

process_timestamp class-attribute instance-attribute

process_timestamp: float | None = field(
    default=None, init=False
)

Unix timestamp of when this job was processed from the working queue.

qid class-attribute instance-attribute

qid: str | None = field(default=None, init=False)

The ID of the queue that ran this job.

result class-attribute instance-attribute

result: Any = field(default=None, init=False)

Result of this job, if it exited gracefully.

start_timestamp class-attribute instance-attribute

start_timestamp: float | None = field(
    default=None, init=False
)

Unix timestamp of when this job started.

submit_timestamp class-attribute instance-attribute

submit_timestamp: float | None = field(
    default=None, init=False
)

Unix timestamp of when this job was submitted.

Functions

get_exit_code

get_exit_code() -> int | None

Exit code of the job.

Returns:

Type Description
int | None

...

get_finish_timestamp

get_finish_timestamp() -> datetime | None

Returns a datetime object of the time this data finished.

Returns:

Type Description
datetime | None

...

get_processed_timestamp

get_processed_timestamp() -> datetime | None

Returns a datetime object of the time this data was processed.

Returns:

Type Description
datetime | None

...

get_seconds_running

get_seconds_running() -> float | None

The number of seconds a job was running for.

Returns:

Type Description
float | None

...

Examples:

>>> from ppqueue import Queue
>>> from time import sleep
...
>>> with Queue() as queue:
...     for i in range(5):
...         jobs = queue.map(sleep, [1, 2, 3])
...
>>> [int(job.get_seconds_running()) for job in jobs]
[1, 2, 3]

get_seconds_total

get_seconds_total() -> float | None

Returns the waiting + running duration of this job.

Returns:

Type Description
float | None

...

Examples:

>>> job.get_seconds_total()

get_seconds_waiting

get_seconds_waiting() -> float | None

The amount of time a data has spent in the waiting queue.

Returns:

Type Description
float | None

...

Examples:

>>> job.get_seconds_waiting()

get_start_timestamp

get_start_timestamp() -> datetime | None

Returns a datetime object of the time this data was started.

Returns:

Type Description
datetime | None

...

get_submit_timestamp

get_submit_timestamp() -> datetime | None

The time this job was submitted.

Returns:

Type Description
datetime | None

...

Examples:

>>> job.get_submit_timestamp()