oban-bg/oban-py
Tentang
ππ Robust job orchestration framework for Python, backed by modern PostgreSQL
DataYang dapat Anda lakukan
- 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.
- Multi-Process Execution β Bypass the GIL and utilize multiple cores for CPU-intensive workloads. Jobs are distributed across worker processes with oban start --processes.
Pertumbuhan bintang terukur
- dalam 24 jam
- 0
- dalam 7 hari
- 0
- dalam 15 hari
- 0
- dalam 1 bulan
- Mengumpulkan riwayat
Perubahan bersih pada periode yang tumpang tindih, bukan total harian. Pengukuran yang belum tersedia dibiarkan kosong. Bintang menunjukkan perhatian, bukan kualitas.
README.md
Asli
Oban is a sophisticated job orchestration framework for Python, backed by PostgreSQL.
Reliable,
observable, and loaded with enterprise grade features.
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.
Multi-Process Execution β Bypass the GIL and utilize multiple cores for CPU-intensive workloads. Jobs are distributed across worker processes with
oban start --processes.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.
Unique Jobs β Duplicate work can be avoided through unique job controls. Uniqueness can be enforced at the argument, queue, worker and even sub-argument level for any period of time.
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.
Recorded Results β Return a
Recordfrom a worker to store its result on the job for later retrieval.Testing Helpers β Run jobs inline or manually during tests, assert on enqueued jobs, and drain queues on demand.
Telemetry Integration β Job and queue life-cycle events are emitted through
oban.telemetry. This enables simple logging, error reporting and health checkups without plug-ins.Web Dashboard β Monitor queues, inspect jobs, and view execution metrics through Oban Web. Run the standalone dashboard via Docker for a complete overview of your job processing system.
π Oban Pro
Oban Pro is a licensed add-on that expands what Oban is capable of while making complex workflows possible.
Drop-In Optimizations β Switch to Pro for automatic bulk inserts, bulk acking, accurate orphan rescue, and constraint-backed unique jobs, with no code changes required.
Erlang Notifier β Replace Postgres pub/sub with direct communication between processes. Works through transaction poolers, without a payload size limit, and keeps notifications out of the database.
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.
Pro Pruner β Fine-grained retention rules per queue, worker, or state. Prune on a cron schedule, manage rules at runtime, and archive jobs rather than deleting them.
Relay β Dispatch jobs and await their results with synchronous-style semantics, even when jobs execute on different servers.
Awaiting Signals β Pause a job mid-execution to wait for an external decision, then resume when a signal arrives. Ideal for approval flows and third-party callbacks.
Durable Workflows β Compose jobs with dependencies for sequential, fan-out, and fan-in patterns. Sub-workflows, result sharing, cascading functions, and runtime grafting for dynamic pipelines.
Chunks β Process jobs together in groups by size or wait time, e.g. 1,000 jobs or every 10 seconds, and apply outcomes to individual jobs.
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), start processing with the CLI (or embedded mode), and enqueue jobs.
Define a worker to process jobs:
from oban import worker @worker(queue="exports", max_attempts=5) class ExportWorker: async def process(self, job): report = await generate_report(job.args["report_id"]) await send_to_user(job.args["email"], report)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:10Or embed in your application (FastAPI, Django, etc.):
from oban import Oban oban = Oban(pool=pool, queues={"exports": 10}) async with oban: ... # Run your appEnqueue jobs from anywhere in your app:
# Enqueue one job await ExportWorker.enqueue({"report_id": 123, "email": "[email protected]"}) # Or many jobs at once await oban.enqueue_many( ExportWorker.new({"report_id": report_id, "email": "[email protected]"}) for report_id in [1, 2, 3] )
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
Jelajahi proyek terkait
Memuatβ¦