Installation
- Python 3.11, 3.12, or 3.13
- Celery 5.3 or later
- urllib3 2.0 or later (installed automatically)
sluice.init()
The single public API for V0. Call this once at application startup, before Celery workers begin processing tasks.
Parameters
Both parameters are keyword-only (no positional arguments).
Environment variables
The resolution order is: explicit parameter > environment variable. If neither is set,
init() raises SluiceConfigError.
Behavior
Whensluice.init() is called, the SDK:
-
Validates configuration — checks that
api_keyandconnection_idare non-empty and that the connection ID is a valid UUID. RaisesSluiceConfigErrorimmediately if validation fails. - Detects framework — checks whether Django is installed. If Django is detected, the SDK eagerly installs its Celery Bootstep on the current Celery app.
-
Connects to
celeryd_initsignal — regardless of framework, the SDK registers a handler on Celery’sceleryd_initsignal. This fires when each worker process starts and installs the monitoring Bootstep. -
Auto-configures Celery — the Bootstep sets three critical flags that are
Falseby default in Celery: - Captures and forwards events — listens to all Celery task and worker events, normalizes them to Sluice’s unified model, batches them, and sends them to the Sluice API over HTTPS.
Exceptions
Configuration errors are the only exceptions the SDK raises. All runtime errors — network failures, API errors, serialization issues — are caught and logged. The SDK never crashes your Celery worker.
Celery state mapping
The SDK maps Celery’s native task states to Sluice’s unified model:Supported versions
Where to call init()
The init() call must execute before Celery workers start. The exact location depends on your framework: