Python Django:芹菜工人没有开始(没有任何错误)
我正试图在我的Django应用程序中配置Python Django:芹菜工人没有开始(没有任何错误),python,django,celery,django-celery,djcelery,Python,Django,Celery,Django Celery,Djcelery,我正试图在我的Django应用程序中配置djcelery,该应用程序由rabbitmq服务器支持,服务器位于Ubuntu 14.04上,主机位于Google Compute Engine上 尝试使用以下命令在调试模式下启动芹菜时:python manage.py芹菜worker-B-E--loglevel=debug,命令将终止,并显示以下输出: [2016-03-24 12:16:09,568: DEBUG/MainProcess] | Worker: Preparing bootsteps.
djcelery
,该应用程序由rabbitmq
服务器支持,服务器位于Ubuntu 14.04
上,主机位于Google Compute Engine
上
尝试使用以下命令在调试模式下启动芹菜时:python manage.py芹菜worker-B-E--loglevel=debug
,命令将终止,并显示以下输出:
[2016-03-24 12:16:09,568: DEBUG/MainProcess] | Worker: Preparing bootsteps.
[2016-03-24 12:16:09,571: DEBUG/MainProcess] | Worker: Building graph...
[2016-03-24 12:16:09,572: DEBUG/MainProcess] | Worker: New boot order: {Timer, Hub, Queues (intra), Pool, Autoscaler, StateDB, Autoreloader, Beat, Consumer}
[2016-03-24 12:16:09,575: DEBUG/MainProcess] | Consumer: Preparing bootsteps.
[2016-03-24 12:16:09,576: DEBUG/MainProcess] | Consumer: Building graph...
[2016-03-24 12:16:09,577: DEBUG/MainProcess] | Consumer: New boot order: {Connection, Events, Mingle, Tasks, Control, Agent, Heart, Gossip, event loop}
<user>@<gce.host>:~/path/to/my/project$
在settings.py文件中,我添加了:
import djcelery
djcelery.setup_loader()
MIDDLEWARE_CLASSES = [ 'django.middleware.transaction.TransactionMiddleware',
..]
INSTALLED_APPS = ['djcelery',
..]
芹菜.py的含量如下:
from __future__ import absolute_import
import os
from datetime import timedelta
from celery import Celery
from celery.schedules import crontab
from django.conf import settings
# set the default Django settings module for the 'celery' program.
os.environ.setdefault('DJANGO_SETTINGS_MODULE', '<my_project>.settings')
app = Celery('<my_project>')
# Using a string here means the worker will not have to
# pickle the object when using Windows.
app.config_from_object('<my_project>.settings')
# app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)
app.conf.update(
CELERY_ACCEPT_CONTENT = ['json'],
CELERY_TASK_SERIALIZER = 'json',
CELERY_RESULT_SERIALIZER = 'json',
BROKER_URL = 'amqp://<user>:<password>@localhost:5672//',
# BROKER_URL = 'django://',
CELERY_RESULT_BACKEND = "amqp",
CELERY_IMPORTS = ("<module1>.tasks", "<module2>.tasks.tasks", "<module3>.tasks.tasks"),
CELERY_ALWAYS_EAGER = False,
# CELERY_RESULT_BACKEND='djcelery.backends.database:DatabaseBackend',
# CELERY_TIMEZONE = 'Europe/London'
CELERY_TIMEZONE = 'UTC',
CELERYBEAT_SCHEDULE = {
'debug-test': {
'task': '<module1>.tasks.test_celery',
'schedule': timedelta(seconds=5),
# 'args': (1, 2)
},
}
)
来自未来导入绝对导入
导入操作系统
从日期时间导入时间增量
从芹菜进口芹菜
从celery.schedules导入crontab
从django.conf导入设置
#为“芹菜”程序设置默认的Django设置模块。
os.environ.setdefault('DJANGO\u SETTINGS\u MODULE','.SETTINGS')
app=芹菜(“”)
#在这里使用字符串意味着工人不必
#使用Windows时对对象进行pickle。
app.config_from_对象(“.settings”)
#应用程序.自动发现\u任务(lambda:设置.已安装的\u应用程序)
app.conf.update(
芹菜接受内容=['json'],
芹菜任务序列化程序='json',
芹菜\u结果\u序列化程序='json',
BROKER_URL='amqp://:@localhost:5672/',
#BROKER_URL='django://',
芹菜\u结果\u BACKEND=“amqp”,
芹菜进口=(“.tasks”、“.tasks.tasks”、“.tasks.tasks”),
芹菜总是渴望=假,
#芹菜\u结果\u BACKEND='dj芹菜.backends.database:DatabaseBackend',
#芹菜时区='欧洲/伦敦'
芹菜时区='UTC',
CELERYBEAT_时间表={
“调试测试”:{
“任务”:“任务。测试芹菜”,
“计划”:时间增量(秒=5),
#“args”:(1,2)
},
}
)
我终于能够解决这个问题了。我的系统上的芹菜
和django芹菜
软件包的版本不同
ubuntu@my-host:~/path/to/project$ pip freeze | grep celery
celery==3.1.21
django-celery==3.1.17
将芹菜版本更改为3.1.17
修复了它。要更改pip的软件包版本,请使用:
ubuntu@my-host:~/path/to/project$ sudo pip install -I celery==3.1.17
ubuntu@my-host:~/path/to/project$ sudo pip install -I celery==3.1.17