Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

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

Project Description

Celery application implementation that allows celery tasks to cooperate with
multi-tenancy provided by [django-tenant-schemas]( and
[django-tenants]( packages.


$ pip install tenant-schemas-celery
$ pip install django-tenants


* Define a celery app using given `CeleryApp` class.

import os
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'app.settings')

from django.conf import settings

from import CeleryApp

app = CeleryApp()
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)

This assumes a fresh Celery 3.1.13 application. For previous versions, the key is to create a new `CeleryApp` instance that will be used to access task decorator from.

* Replace your `@task` decorator with `@app.task`

from django.db import connection
from myproject.celery import app

def my_task():
print connection.schema_name

* Run celery worker (`myproject.celery` is where you've defined the `app` variable)

$ celery worker -A myproject.celery

* Post registered task. The schema name will get automatically added to the task's arguments.

from myproject.tasks import my_task

The `TenantTask` class transparently inserts current connection's schema into
the task's kwargs. The schema name is then popped from the task's kwargs in
`task_prerun` signal handler, and the connection's schema is changed
Release History

Release History

This version
History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
tenant-schemas-celery-0.1.7.tar.gz (4.5 kB) Copy SHA256 Checksum SHA256 Source May 7, 2017

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting