I'm trying to use MongoDB as the message queue for Celery (in a Django app). The current development version of Celery (2.2.0rc2) is supposed to let you do this, but I can't seem to get any workers to pick up tasks I'm creating.
我正在尝试使用MongoDB作为Celery的消息队列(在Django应用程序中)。 Celery(2.2.0rc2)的当前开发版本应该允许你这样做,但我似乎无法让任何工作人员去接受我正在创建的任务。
Versions: celery v2.2.0rc3
mongodb 1.6.5
pymongo 1.9
django-celery 2.2.0rc2
版本:芹菜v2.2.0rc3 mongodb 1.6.5 pymongo 1.9 django-celery 2.2.0rc2
In my settings, I have:
在我的设置中,我有:
CELERY_RESULT_BACKEND = "mongodb"
CELERY_MONGODB_BACKEND_SETTINGS = {
# Shouldn't need these - defaults are correct.
"host": "localhost",
"port": 27017,
"database": "celery",
"taskmeta_collection": "messages",
}
BROKER_BACKEND = 'mongodb'
BROKER_HOST = "localhost"
BROKER_PORT = 27017
BROKER_USER = ""
BROKER_PASSWORD = ""
BROKER_VHOST = ""
import djcelery
djcelery.setup_loader()
I've created a test tasks.py file as follows:
我已经创建了一个测试tasks.py文件,如下所示:
from celery.decorators import task
@task()
def add(x, y):
return x + y
If I fire up celeryd in the background, it appears to start normally. I then open a python shell and run the following:
如果我在后台启动芹菜,它似乎正常启动。然后我打开一个python shell并运行以下命令:
>>> from myapp.tasks import add
>>> result = add.delay(5,5)
>>> result
<AsyncResult: 7174368d-288b-4abe-a6d7-aeba987fa886>
>>> result.ready()
False
Problem is that no workers ever pick up the tasks. Am I missing a setting or something? How do I point celery to the message queue?
问题是没有工人接过任务。我错过了一个设置或什么?如何将芹菜指向消息队列?
4 个解决方案
#1
2
We had this same issue. While the doc says all tasks should be registered in Celery by calling
我们遇到了同样的问题。虽然文档说所有任务都应该通过调用在Celery中注册
import djcelery
djcelery.setup_loader()
it wasn't working properly. So, we still used the
它运作不正常。所以,我们仍然使用
CELERY_IMPORTS = ('YOUR_APP.tasks',)
setting in settings.py. Also, make sure you restart Celery if you add a new task because Celery has to register the tasks when it first starts.
在settings.py中设置。此外,如果添加新任务,请确保重新启动Celery,因为Celery必须在首次启动时注册任务。
Django, Celerybeat and Celery with MongoDB as the Broker
Django,Celerybeat和Celery以MongoDB为经纪人
#2
0
Remember that Kombu work only with mongo 1.3+ because it need the functionality findandmodify. If you are on ubuntu the last version in repository is the 1.2, than doesn't work.
请记住,Kombu只能使用mongo 1.3+,因为它需要findandmodify功能。如果你在ubuntu上,那么存储库中的最后一个版本是1.2,而不是工作。
Maybe you have also to set BROKER_VHOST = "dbname"
也许你还要设置BROKER_VHOST =“dbname”
Keep me posted if it works
如果有效,请让我发布
#3
0
Be sure to add this to your settings, or the workers can't find the task and will fail silently.
请务必将此添加到您的设置中,否则工作人员将无法找到该任务并将无提示失败。
CELERY_IMPORTS = ("namespace", )
#4
0
I had the same issue but when I upgraded to celery 2.3.3 everything worked like a charm.
我有同样的问题但是当我升级到芹菜2.3.3时,一切都像魅力一样。
#1
2
We had this same issue. While the doc says all tasks should be registered in Celery by calling
我们遇到了同样的问题。虽然文档说所有任务都应该通过调用在Celery中注册
import djcelery
djcelery.setup_loader()
it wasn't working properly. So, we still used the
它运作不正常。所以,我们仍然使用
CELERY_IMPORTS = ('YOUR_APP.tasks',)
setting in settings.py. Also, make sure you restart Celery if you add a new task because Celery has to register the tasks when it first starts.
在settings.py中设置。此外,如果添加新任务,请确保重新启动Celery,因为Celery必须在首次启动时注册任务。
Django, Celerybeat and Celery with MongoDB as the Broker
Django,Celerybeat和Celery以MongoDB为经纪人
#2
0
Remember that Kombu work only with mongo 1.3+ because it need the functionality findandmodify. If you are on ubuntu the last version in repository is the 1.2, than doesn't work.
请记住,Kombu只能使用mongo 1.3+,因为它需要findandmodify功能。如果你在ubuntu上,那么存储库中的最后一个版本是1.2,而不是工作。
Maybe you have also to set BROKER_VHOST = "dbname"
也许你还要设置BROKER_VHOST =“dbname”
Keep me posted if it works
如果有效,请让我发布
#3
0
Be sure to add this to your settings, or the workers can't find the task and will fail silently.
请务必将此添加到您的设置中,否则工作人员将无法找到该任务并将无提示失败。
CELERY_IMPORTS = ("namespace", )
#4
0
I had the same issue but when I upgraded to celery 2.3.3 everything worked like a charm.
我有同样的问题但是当我升级到芹菜2.3.3时,一切都像魅力一样。