Django celery running only two tasks at once?

℡╲_俬逩灬. 提交于 2019-12-24 05:32:20

问题


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.

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?


回答1:


Have you checked the concurrency setting of your 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.

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

 -c N

where N is number of parallel tasks



来源:https://stackoverflow.com/questions/15307609/django-celery-running-only-two-tasks-at-once

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