Skip to content

Latest commit

 

History

History
41 lines (33 loc) · 1.53 KB

File metadata and controls

41 lines (33 loc) · 1.53 KB

SavewebHQ Python worker SDK

The SDK talks directly to one PostgreSQL-backed Project Queue. It has no background heartbeat, shard route, generation, or inbound server.

from saveweb_hq import Config, open_project_queue

with open_project_queue(
    Config(
        tracker_url="https://hq.example",
        machine_token=machine_token,
        client_version="sinavideo/2.4.0",
    ),
    "sinavideo",
) as queue:
    response = queue.claim(max_jobs=64)
    for job in response["jobs"]:
        # Upload artifacts to the external Artifact Receiver, then include its
        # receipts in complete().
        ...

Opening a queue generates a fresh seven-character a-z0-9 worker ID, exposed as queue.worker_id and fixed for that queue instance.

Use saveweb_hq.whoami(config) to get the user ID associated with a machine token without opening a project queue.

complete, fail, and extend_lease accept bounded lists matching the Project Queue OpenAPI contract.

With no lease_seconds argument, claim uses the project's recommended_lease_seconds policy. The Python SDK does not renew leases in the background; long-running Python workers must still call extend_lease.

Before claiming, the SDK periodically fetches project policy, clamps the batch size, and applies the cooperative per-worker claim rate with monotonic timing and a randomized initial phase. Explicit retryable HTTP 429 responses are delayed using their precise retry_after_ms and retried automatically. Other transport and API errors are returned to the caller.