本文介绍了使用芹菜+ Redis的巨大延迟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在测试Django + Celery,您好是世界示例。使用RabbitMQ芹菜可以正常工作,但是当我切换到Redis经纪人/结果时,我得到以下信息:
I'm testing Django + Celery, hello world examples. With RabbitMQ celery works fine, but when I switched to Redis broker/result I get following:
%timeit add.delay(1,2).get()
1 loops, best of 3: 503 ms per loop
settings.py
CELERY_RESULT_BACKEND = "redis"
BROKER_URL = 'redis://localhost:6379'
tasks.py
@task()
def add(x, y):
return x + y
上面的测试中是否有任何问题?
Is there any issues in test above?
推荐答案
我发现解决方案是源代码:
I found solution is source code:http://docs.celeryproject.org/en/latest/_modules/celery/result.html#AsyncResult.get
默认情况下为0.5秒。您可以手动更改它,但是不建议使用这种方法来运行任务:
By default it is 0.5 sec. You can change it manually, but it's not recommended way for running tasks:
%timeit add.delay(1,2).get(interval=0.001)
100 loops, best of 3: 3.92 ms per loop
这篇关于使用芹菜+ Redis的巨大延迟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!