Skip to main content

Installation

Requirements:
  • 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

When sluice.init() is called, the SDK:
  1. Validates configuration — checks that api_key and connection_id are non-empty and that the connection ID is a valid UUID. Raises SluiceConfigError immediately if validation fails.
  2. Detects framework — checks whether Django is installed. If Django is detected, the SDK eagerly installs its Celery Bootstep on the current Celery app.
  3. Connects to celeryd_init signal — regardless of framework, the SDK registers a handler on Celery’s celeryd_init signal. This fires when each worker process starts and installs the monitoring Bootstep.
  4. Auto-configures Celery — the Bootstep sets three critical flags that are False by default in Celery:
  5. 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.
Call init() only once. If called multiple times, the SDK logs a warning and ignores subsequent calls. Only the first invocation takes effect.

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: