Skip to content

common

common

JobState dataclass

The state of a job which keeps its state (see RedisStateProtocol) as it was read from the job hash. It gives the dispatcher one thing to hand over instead of the raw redis fields.

Attributes:

  • id (str) –

    The unique identifier of the job.

  • status (Status) –

    The current status of the job.

  • last_update (str | None) –

    ISO timestamp of the last status change.

  • result (JobResult | None) –

    The result of a succeeded job.

  • message (str | None) –

    The error message of a failed job, or why a dismissed one stopped.

  • progress (int | None) –

    The percentage (0-100) the job reported last, None if it reported none (yet).

Source code in src/qgis_server_light/interface/dispatcher/common.py
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
@dataclass
class JobState:
    """The state of a job which keeps its state (see `RedisStateProtocol`) as
    it was read from the job hash. It gives the dispatcher one thing to hand
    over instead of the raw redis fields.

    Attributes:
        id: The unique identifier of the job.
        status: The current status of the job.
        last_update: ISO timestamp of the last status change.
        result: The result of a succeeded job.
        message: The error message of a failed job, or why a dismissed one stopped.
        progress: The percentage (0-100) the job reported last, `None` if it
            reported none (yet).
    """

    id: str = field(metadata={"type": "Element"})
    status: Status = field(metadata={"type": "Element"})
    last_update: str | None = field(default=None, metadata={"type": "Element"})
    result: JobResult | None = field(default=None, metadata={"type": "Element"})
    message: str | None = field(default=None, metadata={"type": "Element"})
    progress: int | None = field(default=None, metadata={"type": "Element"})

    @property
    def finished(self) -> bool:
        """If the job reached a final status, nothing changes on it anymore."""
        return self.status in (Status.SUCCESS, Status.FAILURE, Status.DISMISSED)

finished: bool property

If the job reached a final status, nothing changes on it anymore.

id: str = field(metadata={'type': 'Element'}) class-attribute instance-attribute

last_update: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute

message: str | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute

progress: int | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute

result: JobResult | None = field(default=None, metadata={'type': 'Element'}) class-attribute instance-attribute

status: Status = field(metadata={'type': 'Element'}) class-attribute instance-attribute

__init__(id: str, status: Status, last_update: str | None = None, result: JobResult | None = None, message: str | None = None, progress: int | None = None) -> None

Status

Bases: Enum

Source code in src/qgis_server_light/interface/dispatcher/common.py
 9
10
11
12
13
14
class Status(Enum):
    SUCCESS = "succeed"
    FAILURE = "failed"
    RUNNING = "running"
    QUEUED = "queued"
    DISMISSED = "dismissed"

DISMISSED = 'dismissed' class-attribute instance-attribute

FAILURE = 'failed' class-attribute instance-attribute

QUEUED = 'queued' class-attribute instance-attribute

RUNNING = 'running' class-attribute instance-attribute

SUCCESS = 'succeed' class-attribute instance-attribute

Worker dataclass

A worker the dispatcher has seen alive on the queue. It carries what a consumer needs to tell whether jobs can be served and what the worker is doing right now.

Attributes:

  • id (str) –

    The unique identifier of the worker.

  • last_seen (datetime) –

    The time of the last heartbeat of the worker, always timezone aware.

  • info (EngineInfo) –

    The info the worker published with its last heartbeat (status, QGIS version, start time).

Source code in src/qgis_server_light/interface/dispatcher/common.py
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
@dataclass
class Worker:
    """A worker the dispatcher has seen alive on the queue. It carries what a
    consumer needs to tell whether jobs can be served and what the worker is doing
    right now.

    Attributes:
        id: The unique identifier of the worker.
        last_seen: The time of the last heartbeat of the worker, always timezone aware.
        info: The info the worker published with its last heartbeat (status, QGIS
            version, start time).
    """

    id: str
    last_seen: datetime
    info: EngineInfo

id: str instance-attribute

info: EngineInfo instance-attribute

last_seen: datetime instance-attribute

__init__(id: str, last_seen: datetime, info: EngineInfo) -> None