本文介绍了可以将django-celery-beat与django-tenant一起使用吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用芹菜来安排任务.到目前为止,一切都很好,包括托管在AWS上.但是,我决定使用django-tenant将我的单个应用程序转换为多租户.这样,我可以完美地创建子域.

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

但是,当运行命令 celery -A myproject worker -B 时,尽管没有显示任何错误,但在我看来,他无法为创建的模式运行(仅测试创建的模式)

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).

我尝试使用 python manage.py tenant_command celery worker -B --loglevel = info --schema = myschema 指定模式.但我收到以下错误:

I tried to specify the schema, using python manage.py tenant_command celery worker -B --loglevel = info --schema = myschemabut 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!

推荐答案

您应该扩展celery Task实现并注入db_schema并使用它代替

You should extend celery Task implementation and inject the db_schema and use it instead

但是也可以不重新发明轮子并使用 https://github.com/maciej-gol/tenant-schemas-celery

But it would be also OK not to reinvent the wheel and usehttps://github.com/maciej-gol/tenant-schemas-celery

这篇关于可以将django-celery-beat与django-tenant一起使用吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 17:54