Skip to main content

Import and export backends

Added in 1.0.1 Changed in 1.0.19 Changed in 1.0.23
BackendEnumBehaviour
InlineINLINERuns in the request process
Python queuePYTHON_QUEUEProcess-local worker queue
Background workerWORKERThe project-selected worker provider

WORKER retains stored value 3 for all providers, including Celery. Forms and ExecutionBackendSelect have one is_available and choice_value, without provider-specific flags. Unavailable execution is disabled and rejected on POST. A configured worker is the default; otherwise Python queue is used.

Common task mechanism​

Added in 1.0.19

Import and export use the provider-neutral background task protocol. ImportExportDispatchService saves history and passes the task definition and JSON arguments to WorkerService. The shared service selects the provider and publishes after commit. Neither the handler, forms, nor dispatch know which worker library is selected.

The built-in task is process_import_export, queue chassis-import-export. Arguments are kind and a history UUID string. Import and export share one handler and one description in django_chassis.worker_tasks.TASKS.

Dramatiq​

Added in 1.0.19
pip install 'django-chassis[dramatiq]'

Configure the project broker first, for example through django-dramatiq or dramatiq-postgres[django] and DRAMATIQ_BROKER. Then register Chassis tasks in both web and worker processes after Django/broker setup:

from django_chassis.services import WorkerService

WorkerService.register_tasks()

Chassis reuses the project broker. Include chassis-import-export if workers are restricted to named queues, and configure Django connection cleanup in the integration. Web and workers share the database and media storage.

Celery​

pip install 'django-chassis[celery]'

Configure Celery and enable Django task-module discovery so it imports django_chassis.tasks. Set CHASSIS_WORKER_PROVIDER = 'celery' to select Celery when Dramatiq is also configured. The task is registered as process_import_export. If workers listen only to named queues, include chassis-import-export. To enqueue it from Python, import IMPORT_EXPORT_TASK from django_chassis.worker_tasks and call IMPORT_EXPORT_TASK.delay(kind=..., history_id=...). This uses the selected worker provider and returns None. Importing django_chassis.tasks is safe without Celery installed. For Celery-only risk tasks, see Risk observation.

Processing rules​

Both external adapters translate the same task metadata: three retries, 1–30 second backoff, five-minute time limit, and one-day max age. Domain failures recorded as FAILED are terminal; exceptions escaping processing use worker retries. History row locks remain held through processing; completed histories are skipped on redelivery. Database transactions do not roll back external storage writes, so domain logic and storage must tolerate at-least-once execution.

Inline and Python queue​

Inline keeps the request open until completion. PythonQueueWorkerProvider runs in the local process and suits development or a single-process deployment. Use the external worker backend for multiple web workers.

See also​