Skip to main content Module db Copy item path Source cancel_job Cancel a pending or processing job. Returns the previous status. claim Atomically claim the next eligible job for a specific worker. claim_next_job Atomically claim the next pending job by selecting and marking it as
processing in a single transaction. Returns the job ID and its data,
or None if no pending jobs are available. claim_with_lease Claim the next eligible job for a worker and record the configured lease timeout. count_by_status Count jobs by status. get_attempt_count Get the recorded attempt count for a job. get_job Get a single job by ID. Returns (id, priority, status, data_json, error_message). get_job_details Get a structured view of a job for debugging and UI inspection. get_next_pending Get the next pending job (highest priority, oldest first).
Returns the job ID and its data as a JSON value. heartbeat Update the heartbeat timestamp for a processing job. insert_job Insert a new job into the queue. insert_job_full Insert a new job with full canonical retry lineage. insert_job_with_trace Insert a new job into the queue with an optional trace ID. is_cancelled Check if a job has been cancelled (used by executor during execution). list_all_jobs List all jobs ordered by status then priority then creation time.
Returns tuples of (id, status, data_json). mark_completed Mark a job as completed and set completed_at. mark_completed_owned Mark a job as completed, optionally validating worker ownership. mark_failed Mark a job as failed with an error message and set completed_at. mark_failed_owned Mark a job as failed, optionally validating worker ownership. mark_failed_with_retry Mark a failed job for retry with backoff. Sets next_run_at based on
the failure class and attempt count, then resets status to pending. mark_failed_with_retry_owned Mark a failed job for retry or permanent failure while validating worker ownership. mark_processing Mark a job as processing and set started_at. open_database Open (or create) the queue database. Pass None for an in-memory database. prune_old_jobs Delete completed/failed/cancelled jobs older than the specified number of days.
Returns the number of jobs deleted. reclaim_stale Reclaim jobs that have been processing but have not sent a heartbeat
within stale_secs seconds. Resets them to pending with worker_id
cleared. Returns the number of jobs reclaimed. reorder_pending Atomically update the priority of a pending job. requeue_interrupted Re-queue any jobs that were mid-processing when the app crashed.
Returns the number of jobs requeued. update_canonical_lineage Persist canonical retry lineage fields for a job. update_priority Update the priority of a job. JobRow Row data for a single job.