Je sais que la fin
Mais je suis tombé sur la même question aujourd'hui, a passé près d'une heure pour trouver la solution exacte. Je pensais que cela pourrait aider quelqu'un d'autre
j'utilise la version de céleri 4.1.0
espère que vous avez configuré correctement RabbitMQ, sinon s'il vous plaît le configurer comme indiqué dans la page http://docs.celeryproject.org/en/latest/getting-started/brokers/rabbitmq.html#setting-up-rabbitmq
également vérifier si le courtier croix L'URL est correcte. Voici l'url brocker syntaxe AMQP: // user_name: mot de passe @localhost/nom_hôte
Vous pourriez ne pas avoir besoin de spécifier le numéro de port, car il sélectionne automatiquement la valeur par défaut un
Si vous suivez les mêmes variables à partir du lien de tutoriel de configuration ci-dessus votre url Brocker sera comme AMQP: // myuser: mypassword @ localhost/myvhost
Suivre cette structure de projet
Project
../app
../Project
../settings.py
../celery.py
../tasks.py
../celery_config.py
celery_config.py
# - - - - - - - - - -
# BROKER SETTINGS
# - - - - - - - - - -
# BROKER_URL = os.environ['APP_BROKER_URL']
BROKER_HEARTBEAT = 10
BROKER_HEARTBEAT_CHECKRATE = 2.0
# Setting BROKER_POOL_LIMIT to None disables pooling
# Disabling pooling causes open/close connections for every task.
# However, the rabbitMQ cluster being behind an Elastic Load Balancer,
# the pooling is not working correctly,
# and the connection is lost at some point.
# There seems no other way around it for the time being.
BROKER_POOL_LIMIT = None
BROKER_TRANSPORT_OPTIONS = {'confirm_publish': True}
BROKER_CONNECTION_TIMEOUT = 20
BROKER_CONNECTION_RETRY = True
BROKER_CONNECTION_MAX_RETRIES = 100
celery.py
from __future__ import absolute_import, unicode_literals
from celery import Celery
from Project import celery_config
app = Celery('Project',
broker='amqp://myuser:[email protected]/myvhost',
backend='amqp://',
include=['Project'])
# Optional configuration, see the application user guide.
# app.conf.update(
# result_expires=3600,
# CELERY_BROKER_POOL_LIMIT = None,
#)
app.config_from_object(celery_config)
if __name__ == '__main__':
app.start()
tasks.py
from __future__ import absolute_import, unicode_literals
from .celery import app
@app.task
def add(x, y):
return x + y
Lancez ensuite la céleri avec « céleri -Un travailleur du projet d'info -l » à partir du répertoire du projet
Tout ira bien.
vérifier si le statut 'rabbitmqctl' indique que le noeud est en cours d'exécution ou non –
Vérifiez si votre serveur 'RabbitMq' est en cours d'exécution. Sinon, vous pouvez l'exécuter en utilisant: 'rabbitmq-server'. –