Is it possible to use django-celery-beat with django-tenant?

穿精又带淫゛_ 提交于 2021-01-28 21:09:36

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!