skillfed

tenant-schemas-celery

Celery integration for django-tenant-schemas and django-tenants

tenant-schemas-celery v5.0.0 213.3K downloads/30d#9,441 on PyPI223
Permissive license MIT Active released

What it is and what it does

tenant-schemas-celery bridges Celery and multi-tenant applications by automatically injecting the current tenant's schema name into task arguments and restoring the correct schema context when tasks execute. This allows background jobs to operate safely within isolated tenant databases without manual schema switching. The package provides a drop-in CeleryApp subclass and a TenantTask base class that transparently handle schema context, plus optional schedulers for celery beat that iterate over all tenant schemas to run periodic tasks in each one.

The package supports multiple databases, tenant object caching to reduce refetch overhead, and database-driven periodic task scheduling. It requires Python >=3.11 and Celery >=5. The codebase is stable and rarely updated, but maintainers respond quickly to issues.

Use it for:

  • Run background jobs (email, reports, cleanup) for each tenant independently without cross-tenant data leakage.
  • Schedule periodic maintenance tasks across all tenants using celery beat.
  • Execute long-running operations asynchronously while preserving tenant isolation and schema context.
  • Store periodic task definitions per-tenant in the database for dynamic scheduling.
  • Cache tenant objects across task retries to reduce database queries in high-frequency scenarios.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Integrates Celery task queuing with multi-tenant Django applications to run asynchronous tasks within isolated tenant schemas, automatically managing schema context across task execution.

Yes—if you use Celery with multi-tenant applications. The package is actively maintained, has no known vulnerabilities, low install friction, and solves the non-trivial problem of schema context management across async task boundaries. The MIT license imposes no restrictions. Install only if you are already committed to both Celery and a multi-tenant architecture; it adds no value as a standalone tool.

Install

tenant-schemas-celery on PyPI

pip

pip install tenant-schemas-celery

uv

uv add tenant-schemas-celery

poetry

poetry add tenant-schemas-celery

Installing tenant-schemas-celery

Before you install

Low friction: single runtime dependency (celery) and a pure-Python wheel. Actively maintained with a recent release (13 days old) and quick issue response, though infrequent commits suggest stable, feature-complete code rather than active development.

License in practice

MIT license permits unrestricted use, modification, and distribution in commercial and private projects with minimal obligations—only attribution required.

Quickstart

pip install tenant-schemas-celery

from tenant_schemas_celery.app import CeleryApp as TenantAwareCeleryApp
app = TenantAwareCeleryApp()
app.config_from_object('django.conf:settings')

@app.task
def my_task():
    print(connection.schema_name)

Requires Python >=3.11, a multi-tenant application using django-tenants, and a running Celery worker.

Verify before relying

  • Whether tenant object caching (tenant_cache_seconds) significantly improves performance in production workloads.
  • Behavior and deadlock risk when celery beat attempts to schedule tasks for newly created tenants before migrations complete.
  • Compatibility with specific versions of django-tenants and whether the package is tested against the latest releases.

Package facts

License MIT (permissive)
Python support supports the current Python release (>=3.11)
Install friction low — pure-Python wheel
Runtime dependencies 1 — celery
Maintenance actively maintained — 13 days since the last release
Last repo commit
First released
Downloads 213,292/month — #9,441 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: tenant_schemas_celery-5.0.0-py3-none-any.whl

Framework :: DjangoLicense :: OSI Approved :: MIT LicenseProgramming Language :: Python

Tags

celery multi-tenant taskstenant-aware async taskscelery schema contextmulti-tenant background jobstenant schema task routingcelery task isolationasync tasks per tenant
multi-tenanttask-queuecelery-integration

More Application Frameworks packages