Skip to main content

Job orchestration framework, backed by PostgreSQL.

Project description

Oban logo

Oban is a sophisticated job orchestration framework for Python, backed by PostgreSQL. Reliable,
observable, and loaded with enterprise grade features.

PyPI Version CI Status Apache 2 License

Table of Contents


[!NOTE]

This README is for the unreleased main branch, please reference the official docs for the latest stable release.


Features

Oban's primary goals are reliability, consistency and observability.

Oban is a powerful and flexible library that can handle a wide range of background job use cases, and it is well-suited for systems of any size. It provides a simple and consistent API for scheduling and performing jobs, and it is built to be fault-tolerant and easy to monitor.

Oban is fundamentally different from other background job processing tools because it retains job data for historic metrics and inspection. You can leave your application running indefinitely without worrying about jobs being lost or orphaned due to crashes.

Advantages Over Other Tools

  • Async Native — Built entirely on asyncio with async/await throughout. Integrates naturally with async web frameworks.

  • Fewer Dependencies — If you are running a web app there is a very good chance that you're running on top of a SQL database. Running your job queue within a SQL database minimizes system dependencies and simplifies data backups.

  • Transactional Control — Enqueue a job along with other database changes, ensuring that everything is committed or rolled back atomically.

  • Database Backups — Jobs are stored inside of your primary database, which means they are backed up together with the data that they relate to.

Advanced Features

  • Isolated Queues — Jobs are stored in a single table but are executed in distinct queues. Each queue runs in isolation, with its own concurrency limits, ensuring that a job in a single slow queue can't back up other faster queues.

  • Queue Control — Queues can be started, stopped, paused, resumed and scaled independently at runtime locally or across all running nodes.

  • Resilient Queues — Failing queries won't crash the entire process, instead a backoff mechanism will safely retry them again in the future.

  • Job Canceling — Jobs can be canceled regardless of which node they are running on. For executing jobs, workers can check for cancellation at safe points and stop gracefully.

  • Triggered Execution — Insert triggers ensure that jobs are dispatched on all connected nodes as soon as they are inserted into the database.

  • Scheduled Jobs — Jobs can be scheduled at any time in the future, down to the second.

  • Periodic (CRON) Jobs — Automatically enqueue jobs on a cron-like schedule. Duplicate jobs are never enqueued, no matter how many nodes you're running.

  • Job Priority — Prioritize jobs within a queue to run ahead of others with ten levels of granularity.

  • Historic Metrics — After a job is processed the row isn't deleted. Instead, the job is retained in the database to provide metrics. This allows users to inspect historic jobs and to see aggregate data at the job, queue or argument level.

  • Node Metrics — Every queue records metrics to the database during runtime. These are used to monitor queue health across nodes and may be used for analytics.

  • Graceful Shutdown — Queue shutdown is delayed so that slow jobs can finish executing before shutdown. When shutdown starts queues are paused and stop executing new jobs. Any jobs left running after the shutdown grace period may be rescued later.

  • Telemetry Integration — Job life-cycle events are emitted via Telemetry integration. This enables simple logging, error reporting and health checkups without plug-ins.

🌟 Oban Pro

Oban Pro is a licensed add-on that expands what Oban is capable of while making complex workflows possible.

  • Optimizations — Switch to Pro for automatic bulk inserts, bulk acking, and accurate orphan rescue.

  • Multi-Process Execution — Bypass the GIL and utilize multiple cores for CPU-intensive workloads. Just switch from oban start to obanpro start.

  • Smart Concurrency — Global limits across all nodes, rate limiting (e.g., 60 jobs/minute), and partitioned queues that apply limits per worker, tenant, or any argument.

  • Workflows — Compose jobs with dependencies for sequential, fan-out, and fan-in patterns. Sub-workflows, cascading functions, and runtime grafting for dynamic pipelines.

  • Unique Jobs — Prevent enqueueing duplicate jobs based on configurable fields and time windows.

Learn more about Oban Pro →

Requirements

Oban requires:

  • Python 3.12+
  • PostgreSQL 14.0+

Installation

See the installation guide for details on installing and configuring Oban for your application.

Quick Start

Get up and running in just a few steps: define a worker (or decorate a function), enqueue jobs, and start processing with the CLI (or embedded mode).

  1. Define a worker to process jobs:

    from oban import worker, Snooze, Cancel
    
    @worker(queue="exports", max_attempts=5)
    class ExportWorker:
        async def process(self, job):
            # Check if user cancelled their export request
            if job.cancelled():
                return Cancel("Export cancelled by user")
    
            report = await generate_report(job.args["report_id"])
    
            # Not ready? Check again in 30 seconds (doesn't count as a failure)
            if report.status == "pending":
                return Snooze(seconds=30)
    
            await send_to_user(job.args["email"], report)
    
  2. Enqueue jobs from anywhere in your app:

    await ExportWorker.enqueue({"report_id": 123, "email": "user@example.com"})
    
  3. Run with the CLI:

    # Install the database schema (once)
    oban install --dsn postgresql://localhost/mydb
    
    # Start processing jobs
    oban start --dsn postgresql://localhost/mydb --queues exports:10
    

    Or embed in your application (FastAPI, Django, etc.):

    from oban import Oban
    
    oban = Oban(pool=pool, queues={"exports": 10})
    
    async with oban:
        ...  # Run your app
    

For more details, see the full documentation.

Also Available

Oban for Elixir — The original Oban, with support for PostgreSQL, MySQL, and SQLite3

Oban for Python and Elixir are fully compatible — they share the same database schema and can run side-by-side, making it easy to use both languages in the same system.

Community

Submit bug reports and upcoming features in the issue tracker

Contributing

To run the Oban test suite you must have Python 3.12+, PostgreSQL 14+, and uv installed. Follow these steps to create the database and run all tests:

make test

To ensure a commit passes CI you should run make ci, or run these checks locally:

  • Lint with Ruff (uv run ruff check)
  • Check formatting (uv run ruff format --check)
  • Check types (uv run ty check)
  • Run tests (uv run pytest)

Building Documentation

There are make commands available to help build and serve the documentation locally:

# Build HTML documentation
make docs

# Build and serve at http://localhost:8000
make docs-serve

# Clean built documentation
make docs-clean

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

oban-0.5.2.tar.gz (63.0 kB view details)

Uploaded Source

Built Distribution

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

oban-0.5.2-py3-none-any.whl (72.1 kB view details)

Uploaded Python 3

File details

Details for the file oban-0.5.2.tar.gz.

File metadata

  • Download URL: oban-0.5.2.tar.gz
  • Upload date:
  • Size: 63.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for oban-0.5.2.tar.gz
Algorithm Hash digest
SHA256 067d2334a3401bb0bcdc4066db20e3954b0fda418c042a2eb8b58f0b0623249a
MD5 4794a8cd4dce13d07249127d5fc448c5
BLAKE2b-256 b5499e41ab39cbf0e2149e4623f285cb723af0683ff1d931c1211ffd1ec0ae0e

See more details on using hashes here.

File details

Details for the file oban-0.5.2-py3-none-any.whl.

File metadata

  • Download URL: oban-0.5.2-py3-none-any.whl
  • Upload date:
  • Size: 72.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for oban-0.5.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d7109746082914eaa83c6ba9ce7a81ab2243f8027d0fbb18890ec3297fab8c5e
MD5 2d1ff54603d36f0b1aca3d4d0143bc87
BLAKE2b-256 6d64cc70c783e0042699ba2d0437e6394fa75e0e4daefeae594478caf2e0dceb

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