FastAPI-XXLJob
fastapi-xxljob is a typed FastAPI adapter for the XXL-JOB 2.4.1 executor protocol. Version 0.1.0 supports FastAPI's asynchronous execution and ASGI lifespan model.
Features
- All five executor endpoints:
/beat,/idleBeat,/run,/kill, and/log. - Sync and async handlers, isolated per FastAPI application.
- Automatic registry renewal, deregistration, callbacks, retry, and failover.
- Bounded requests, constant-time token checks, sensitive-data filtering, and managed logs.
- Async-first API plus explicit
*_syncmethods for scripts and workers.
Install
Requires Python 3.8 or later and FastAPI 0.124.4 or later (before 1.0). Dependency resolution keeps Python 3.8 on FastAPI 0.124.4 while newer Python versions can use newer FastAPI releases.
pip install fastapi-xxljob==0.1.0
Quick start
from fastapi import FastAPI
from fastapi_xxljob import FastAPIXXLJob
app = FastAPI()
xxljob = FastAPIXXLJob(app, {
"XXL_JOB_ADMIN_ADDRESSES": "http://127.0.0.1:8080/xxl-job-admin",
"XXL_JOB_ACCESS_TOKEN": "default_token",
"XXL_JOB_EXECUTOR_APP_NAME": "fastapi-xxljob-executor",
"XXL_JOB_EXECUTOR_ADDRESS": "http://127.0.0.1:8000",
})
@xxljob.on_run("demoJobHandler")
async def demo(param):
return f"processed: {param.executor_params}"
uvicorn app:app --host 0.0.0.0 --port 8000
The protocol routes default to the application root and are hidden from OpenAPI; use XXL_JOB_ROUTE_PREFIX when a prefix such as /xxl-job is required. Run, idle-beat, and kill handlers return XXLJobResponse; log handlers may also return LogResponse.
Callbacks are async-first:
await xxljob.callback_success(log_id=1, log_date_time=1730000000000)
xxljob.callback_failure_sync(log_id=2, log_date_time=1730000000000, message="failed")
Main configuration
| Key | Purpose |
|---|---|
XXL_JOB_ENABLED |
Enable protocol and Admin operations. |
XXL_JOB_ADMIN_ADDRESSES |
Comma-separated Admin base URLs. |
XXL_JOB_ACCESS_TOKEN |
Shared executor token. |
XXL_JOB_EXECUTOR_APP_NAME |
Executor application name. |
XXL_JOB_EXECUTOR_ADDRESS |
Public executor URL. |
XXL_JOB_ROUTE_PREFIX |
Optional route prefix; empty by default. |
XXL_JOB_AUTO_REGISTER |
Start registry renewal with application lifespan. |
XXL_JOB_DEREGISTER_ON_EXIT |
Remove registration during clean shutdown. |
XXL_JOB_REGISTRY_INTERVAL |
Renewal interval in seconds. |
XXL_JOB_HTTP_CONNECT_TIMEOUT |
Admin connection timeout. |
XXL_JOB_HTTP_READ_TIMEOUT |
Admin response timeout. |
XXL_JOB_ADMIN_RETRY_COUNT |
Bounded retry count per Admin address. |
XXL_JOB_MAX_REQUEST_SIZE |
Maximum protocol request bytes. |
XXL_JOB_MAX_PARAM_LENGTH |
Maximum string field length. |
XXL_JOB_CALLBACK_BATCH_MAX_SIZE |
Maximum atomic callback batch size. |
XXL_JOB_CALLBACK_MESSAGE_MAX_LENGTH |
Maximum callback message length. |
XXL_JOB_LOG_ENABLED |
Enable managed library logging. |
XXL_JOB_LOG_FILE_ENABLED |
Enable rotating file output. |
XXL_JOB_LOG_CONSOLE_ENABLED |
Enable console output. |
XXL_JOB_LOG_PATH |
Managed log directory. |
See Getting started, configuration, API reference, and the examples.
Command line
fastapi-xxljob --app app:app register
fastapi-xxljob --app app:create_app --factory status
fastapi-xxljob --app app:app remove
Scope
This package adapts the executor protocol. It intentionally does not schedule business jobs, create a task queue, store task logs, provide a callback outbox, or retry forever.
Metadata
Release files for fastapi-xxljob 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| fastapi_xxljob-0.1.0.tar.gz | 107.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| fastapi_xxljob-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 177.7 kB
Release files / fastapi_xxljob-0.1.0.tar.gz
| Download URL | fastapi_xxljob-0.1.0.tar.gz |
|---|---|
| Size | 107.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c0ee572b3e7680f89d7649863b7bfbc796459e1c72a6f79195ded17909c80e66
|
|
BLAKE2b-256 checksum How to use checksums |
8c1cee2c2f145b792e8a9838f5d27c70be1cd5fff100e98a417dd5cfbc8c28d9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 10, 2026.
Transparency logRelease files / fastapi_xxljob-0.1.0-py3-none-any.whl
| Download URL | fastapi_xxljob-0.1.0-py3-none-any.whl |
|---|---|
| Size | 70.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
29718ab6b4f9fc952abd9bfacca39e47949eabe1d5abf791eafc7f1b3b43fbc6
|
|
BLAKE2b-256 checksum How to use checksums |
17d8f8f5845e874cf70678bde5d79fdaaf20b3a7e7d004409de9bc658f868371
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 10, 2026.
Transparency log