tenant-schemas-celery
Celery integration for django-tenant-schemas and django-tenants
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-celeryuv
uv add tenant-schemas-celerypoetry
poetry add tenant-schemas-celeryInstalling 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
Tags
More Application Frameworks packages
FastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
textualTextual is a Python framework for building…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
mcpBuild and connect to Model Context Protocol…
permissive · top 1,000 on PyPI
WerkzeugWerkzeug is a WSGI utility library providing…
permissive · top 1,000 on PyPI
django-tenantsEnables Django applications to serve multiple…
permissive · top 5,000 on PyPI
django-celery-beatStores Celery periodic task schedules in a…
permissive · top 5,000 on PyPI
django-multitenantAdds multi-tenant database support to Django by…
permissive · top 15,000 on PyPI
sqlalchemy-celery-beatProvides a SQLAlchemy-backed scheduler for…
permissive · top 15,000 on PyPI
celeryCelery is a distributed task queue that lets…
permissive · top 1,000 on PyPI
dvc-taskdvc-task queues and runs background jobs from…
permissive · top 5,000 on PyPI
celery-singletonPrevents duplicate Celery tasks from being…
permissive · top 15,000 on PyPI
dbt-copilot-pythonProvides utility functions for running Django…
unclear · top 15,000 on PyPI
celery-redbeatRedBeat is a Celery Beat scheduler that…
permissive · top 5,000 on PyPI
taskiqTaskiq is an asynchronous distributed task…
permissive · top 5,000 on PyPI