Django芹菜一次只能运行两个任务?

时间:2021-11-08 19:19:00

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        

I have called in a Djagno view.

我在Djagno视图中调用。

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?

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

1 个解决方案

#1


1  

Have you checked the concurrency setting of your worker ?

您是否检查了您的worker的并发设置?

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,那么默认的并发性将为2。这意味着只有两个任务可以同时执行。

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

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

 -c N

where N is number of parallel tasks

N是并行任务的个数

#1


1  

Have you checked the concurrency setting of your worker ?

您是否检查了您的worker的并发设置?

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,那么默认的并发性将为2。这意味着只有两个任务可以同时执行。

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

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

 -c N

where N is number of parallel tasks

N是并行任务的个数