【发布时间】:2020-03-12 09:40:39
【问题描述】:
这是我的项目结构
myproj
│
├── app1
├── __init__.py
├── tasks.py
|---gettingstarted
├── __init__.py
├── urls.py
├── settings.py
│
├── manage.py
|-- Procfile
在入门/设置中:
BROKER_URL = 'redis://'
在 Procfile 中:
web: gunicorn gettingstarted.wsgi --log-file -
worker: celery worker --app=app1.tasks.app
在 app1/tasks.py 中
from __future__ import absolute_import, unicode_literals
import random
import celery
import os
app = celery.Celery('hello')
@app.task
def add(x, y):
return x + y
当我运行“celery worker”时,它给了我:
consumer: Cannot connect to amqp://guest:**@127.0.0.1:5672//: [Errno 61] Connection refused.
【问题讨论】:
-
Celery 正在尝试连接到默认代理 -
rabbitmq,它在 5672 端口上运行。您的代理设置似乎没有被应用。顺便说一句,redis 在端口 6379 上运行。 -
你能试试把
celery.Celery('hello')改成celery.Celery('gettingstarted')吗?
标签: python django redis celery