如何在芹菜中创建多个先进先出队列?

问题描述

我有一台机器上运行着Django网络服务,该作业将作业提交给另一台机器上运行的芹菜工人。

这是我的models.py的样子:

class Department(models.Model):
    name = models.CharField(max_length=200)

class Employee(models.Model):
    name = models.CharField(max_length=200)
    department = models.ForeignKey(Department)

这是我的celery systemd服务文件如下:

[Unit]
Description=celery daemon
After=network.target

[Service]
Type=forking
User=<user>
Group=<group>
WorkingDirectory=<path_to_working_directory>

ExecStart=celery multi start worker -A project --pidfile=<process_id_path> \
--concurrency=1 --logfile=<path_to_logfile> --loglevel=debug
ExecStop=celery multi stopwait worker -A project --pidfile=<process_id_path> \
--concurrency=1 --logfile=<path_to_logfile> --loglevel=debug
ExecReload=celery multi refresh worker -A project --pidfile=<process_id_path> \
--concurrency=1 --logfile=<path_to_logfile> --loglevel=debug

[Install]
WantedBy=multi-user.target

当前,我使用Django信号,每次添加新部门时都会创建一个新队列。但是,如果我在systemd文件中将并发设置为1,则该工作程序一次只能运行一个作业。而且,如果我不提到并发性,那么有时它会从同一队列并行运行多个作业。我希望它并行运行多个作业,但是在给定时间,每个队列中只有一个应在运行。

例如。可以说有3个部门A,B,C。这将创建3个队列,每个部门一个,分别是queueA,queueB,queueC。我希望工作人员同时运行队列A的一项作业,队列B的一项作业和ququeC的一项作业。但是它永远不能同时从一个队列中运行多个作业。

我如何使用芹菜实现这一目标?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)