Skip to main content

A lightweight job queue system with SQLite backend and zero dependencies

Project description

GigQ

Lightweight SQLite Job Queue

PyPI Python Versions License Build Status

GigQ is a Python job queue backed by SQLite. It fits teams and projects that have outgrown a raw for loop with try/except, but don't want to run Redis or any other broker. Define functions, enqueue them, and run one or more workers on any machine that can reach the database file.

from gigq import task, JobQueue, Worker

@task()
def greet(name="world"):
    return f"Hello, {name}!"

queue = JobQueue("jobs.db")
greet.submit(queue, name="Alice")
Worker("jobs.db").start()

You get retries with backoff, crash recovery (stuck work is reclaimed), and queryable status and results from the same DB the workers use.

When to use GigQ

Good fit

  • Local or single-server automation, ETL, scraping batches, ML prep, or any scriptable work you want off the request path
  • A few concurrent worker threads or processes against one SQLite file
  • You are fine storing queue state in a file next to your app

Not the right tool

  • Multi-datacenter orchestration, strict global ordering, or millions of jobs per second
  • When you already run Redis/Kafka/SQS and need their ecosystem

Workflows and parent_results

Wire @task functions into a Workflow, declare dependencies, and submit once. Dependent tasks can declare a parent_results argument; GigQ injects a dict of parent job id → deserialized result so fan-out and fan-in steps can pass data without going through job parameters.

from gigq import task, JobQueue, Workflow, Worker

@task()
def source():
    return {"items": [1, 2, 3]}

@task()
def branch_a(parent_results):
    n = next(iter(parent_results.values()))["items"]
    return {"branch": "a", "len": len(n)}

@task()
def branch_b(parent_results):
    n = next(iter(parent_results.values()))["items"]
    return {"branch": "b", "len": len(n)}

@task()
def merge(parent_results):
    return {"combined": list(parent_results.values())}

queue = JobQueue("jobs.db")
wf = Workflow("fan")
s = wf.add_task(source)
a = wf.add_task(branch_a, depends_on=[s])
b = wf.add_task(branch_b, depends_on=[s])
wf.add_task(merge, depends_on=[a, b])
wf.submit_all(queue)
Worker("jobs.db").start()

Installation

pip install gigq

CLI

The gigq command uses --db (default gigq.db) and a subcommand:

Command Purpose
gigq worker Run a worker; add --concurrency N for threaded workers
gigq list List jobs; optional --status pending (etc.)
gigq status <id> --show-result Inspect a job and its result
gigq stats Aggregate counts by status
gigq submit Enqueue by import path module.function

How it works

Jobs, dependencies, and results live in SQLite tables (jobs, job_executions). Workers claim work in transactions so only one worker runs a given job at a time; multiple threads or processes coordinate through the database file (WAL mode is enabled for less contention). Retries and timeouts are enforced in the worker loop.

Examples

Example Description
examples/parallel_tasks.py Fan-out workers plus a fan-in task using parent_results
examples/data_pipeline.py Linear pipeline: generate → transform → format via parent_results
examples/hyperparameter_tuning.py scikit-learn search with sequential vs parallel workers and crash recovery

Integrations

Documentation

Full guides and API reference: https://kpouianou.github.io/GigQ/

License

This project is licensed under the MIT License — see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gigq-0.5.1.tar.gz (23.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gigq-0.5.1-py3-none-any.whl (24.8 kB view details)

Uploaded Python 3

File details

Details for the file gigq-0.5.1.tar.gz.

File metadata

  • Download URL: gigq-0.5.1.tar.gz
  • Upload date:
  • Size: 23.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for gigq-0.5.1.tar.gz
Algorithm Hash digest
SHA256 6e589293d4174d8b80fe14e8fa63c83da1659cc9838a5998ce5b1a0c095f89e2
MD5 81e303df62ade5ffb723f6ea1a15eb78
BLAKE2b-256 258bed64c638f5d767940e3b17e0a32d66dd2efac300b28c9fbe7a4e00f76c4f

See more details on using hashes here.

File details

Details for the file gigq-0.5.1-py3-none-any.whl.

File metadata

  • Download URL: gigq-0.5.1-py3-none-any.whl
  • Upload date:
  • Size: 24.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for gigq-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f9908e96090c153cfba64a8b48d29a8ffaf452939518fe822e4f0ff13e105cca
MD5 0584d10ec960c65c7cbeb23da356ffe6
BLAKE2b-256 f619284b9ec2690e6807733b73e9062112e4b1ac612379be94f1d6d14cad70e0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page