问题
I am using celery for scheduling tasks. So far everything was fine, including hosted on AWS. However, I decided to transform my single application to multi tenant, using django-tenant. That way, I can create the subdomains perfectly.
./manage.py create_tenant
However, when running the command celery -A myproject worker -B
, despite not showing me any error, It seems to me that he cannot run for the created schema (test with only one created).
I tried to specify the schema, using python manage.py tenant_command celery worker -B --loglevel = info --schema = myschema
but I received the following error:
raise CommandError ("Unknown command:% r"% argv [2])
django.core.management.base.CommandError: Unknown command: 'celery'
If anyone can help me, I really appreciate It! If It is possible to run the command for a specific schema, is It also possible to run globally for all schemas created? Thanks!
回答1:
You should extend celery Task implementation and inject the db_schema and use it instead
But it would be also OK not to reinvent the wheel and use https://github.com/maciej-gol/tenant-schemas-celery
来源:https://stackoverflow.com/questions/60272039/is-it-possible-to-use-django-celery-beat-with-django-tenant