Python Celery任务未处理

时间:2019-05-27 16:21:12

标签: python-3.x redis celery

我正在尝试让Celery在Windows机器上使用Python 3.6进行工作 Redis是我的消息代理。但是,我发现只有大约一半的任务正在执行。其余任务将永远不会得到处理。

为帮助调试此问题,我创建了一个简单的任务, 等待5秒钟,然后写入文件:

@capp.task
def test(inputs):

    print('Entering function Test for simulation: ' + inputs['simulation'])
    time.sleep(5)

    fout = open(inputs['results_path'] + inputs['simulation'], 'w')
    fout.write("Test\n")
    fout.close()

    return 0.0

我在上面称呼如下:

    inputs_array = []
    inputs_array.append({'simulation':'Test1','results_path':results_path})
    inputs_array.append({'simulation':'Test2','results_path':results_path})
    inputs_array.append({'simulation':'Test3','results_path':results_path})
    inputs_array.append({'simulation':'Test4','results_path':results_path})

    print("Entering the Test simulation: ")
    tasks = []

    for inputs in inputs_array:
        task = vmlvsv.app_test.test.apply_async((inputs,), compression='zlib')
        tasks.append(task)

根据建议,我使用了以下celeryconfig设置:

CELERY_ACKS_LATE = True
CELERYD_PREFETCH_MULTIPLIER = 1

但是,仅执行了上述四个任务的一个子集(通常只有2个,有时是3个)?

我在使用芹菜(3.1.25)和Redis(2.10.6) 称为:
芹菜工人-A mp_app.capp --loglevel = debug

任何建议都将受到欢迎!

谢谢!

0 个答案:

没有答案
相关问题