Django芹菜一次只运行两个任务? [英] Django celery running only two tasks at once?

查看:156
本文介绍了Django芹菜一次只运行两个任务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个这样的芹菜任务:

I have a celery task like this:

@celery.task
def file_transfer(password, source12, destination):
    result = subprocess.Popen(['sshpass', '-p', password, 'rsync', '-avz', source12, destination], 
                                    stderr=subprocess.PIPE, stdout=subprocess.PIPE).communicate()[0]                             
    return result        

在Djagno视图中。

I have called in a Djagno view.

用户可以选择多个文件复制到目的地。例如,如果用户一次选择4个文件,芹菜只接受2个任务。有什么问题?

User can select more than one file to copy to the destination. For example if the user selects, 4 files at once, celery accept only 2 tasks. What's wrong?

推荐答案

您是否检查过您的工作人员的并发设置?

Have you checked the concurrency setting of your worker ?

如果你只有一个工作人员在双核机器上运行,默认情况下并发性将为2.这意味着只能执行两个任务。

If for example you have only one worker running on a two-core machine, concurrency by default will be 2. Which means only two tasks can be executed at once.

您可以通过开关从worker命令行更改此设置:

You can change this setting from the worker command-line with the switch:

 -c N

其中N是并行任务数量

这篇关于Django芹菜一次只运行两个任务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆