celery.py 522 B

123456789101112131415161718
  1. import os
  2. os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'application.settings')
  3. from django.conf import settings
  4. from celery import platforms
  5. # 租户模式
  6. if "django_tenants" in settings.INSTALLED_APPS:
  7. from tenant_schemas_celery.app import CeleryApp as TenantAwareCeleryApp
  8. app = TenantAwareCeleryApp()
  9. else:
  10. from celery import Celery
  11. app = Celery(f"application")
  12. app.config_from_object('django.conf:settings')
  13. app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)
  14. platforms.C_FORCE_ROOT = True