2016-07-23 1 views
1

Cette configuration est correcte. Je commençais céleri la mauvaise façon :(, sans préciser le nom du projet. (Travailleur céleri -A hockey_manager information -lDjango 1.9 + tâches non enregistrées de céleri

Je ne mise à niveau vers Django 1.9 de 1.6.5 et je ne peux pas faire la ... le travail de configuration de céleri à nouveau

Après près de deux jours de recherche d'une solution, je ne trouve rien de travail

céleri ne détecte pas mes tâches, j'ai essayé avec:

  • CELERY_IMPORTS
  • autodiscover_tasks
  • bind = True

dépendances

amqp==2.0.3 
celery==3.1.23 
Django==1.9.8 
django-celery==3.1.17 
kombu==3.0.35 

PROJET STRUCTURE

enter image description here

hockey_manager/__ init__.py

from __future__ import absolute_import 

# This will make sure the app is always imported when 
# Django starts so that shared_task will use this app. 
from .celery import app as celery_app 

hockey_manager/celery.py

from __future__ import absolute_import 

import os 

from celery import Celery 

# set the default Django settings module for the 'celery' program. 
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'hockey_manager.settings.common') 

app = Celery('hockey_manager') 

# Using a string here means the worker will not have to 
# pickle the object when using Windows. 
app.config_from_object('django.conf:settings') 

# load task modules from all registered Django app configs. 
app.autodiscover_tasks(['hockey']) 

# Using a string here means the worker will not have to 
# pickle the object when using Windows. 
# app.config_from_object('django.conf:settings') 
# app.autodiscover_tasks(lambda: settings.INSTALLED_APPS) 

# Celery backend configs 
app.conf.update(
    CELERY_RESULT_BACKEND='djcelery.backends.database:DatabaseBackend', 
) 

if __name__ == '__main__': 
    app.start() 


@app.task(bind=True) 
def debug_task(self): 
    print('Request: {0!r}'.format(self.request)) 

hockey_manager/réglages/common.py

INSTALLED_APPS = [ 
    ... 
    'hockey', 
    'djcelery', 
    'kombu.transport.django', 
    ... 
] 

## 
# Celery 
## 
# BROKER_POOL_LIMIT = 3 
BROKER_URL = os.environ.get('CLOUDAMQP_URL') 
#BROKER_URL = 'django://' 

# List of modules to import when celery starts. 
CELERY_IMPORTS = ('hockey.tasks',) 

#: Only add pickle to this list if your broker is secured 
#: from unwanted access (see userguide/security.html) 

CELERY_ACCEPT_CONTENT = ['json'] 
CELERY_TASK_SERIALIZER = 'json' 
CELERY_RESULT_SERIALIZER = 'json' 

hockey/tâches .py

from __future__ import absolute_import 
from hockey_manager.celery import app 

@app.task(name='hockey.tasks.league_schedule_results') 
def league_schedule_results(schedule, statistics): 
    ... 

Erreur de Céleri

[23/07/2016 17: 05: 46231: ERREUR/MainProcess] Reçu non enregistré tâche de type 'hockey.tasks.league_schedule_results'. Le message a été ignoré et ignoré.

Je reçois aussi un avertissement de dévalorisation de AMQP à partir de la version 2.0:

AMQPDeprecationWarning: L'attribut .Transport sur la connexion a été avant la consultée connexion a été établie. Ceci est supporté pour l'instant, mais sera être déprécié dans l'amp 2.2.0.

Since amqp 2.0 you have to explicitly call Connection.connect() 
before using the connection. 

    W_FORCE_CONNECT.format(attr=attr))) 

Répondre

4

utilisation du module django-celery.

ici est link à l'exemple comment utiliser django-celery avec django 1.9.1+

+0

Je suis déjà l'utiliser. C'est montré dans ma liste de dépendances. Version 3.1.17 – Pietro

+0

Je l'utilise avec django 1.9.1 et je n'ai pas besoin de fichier celery.py pour la configuration. Je viens de vous donner une suggestion pour essayer les étapes mentionnées dans le lien. Peut être suivre ces étapes, vous allez configurer le céleri correctement avec django 1.9.1 –

+0

Je vais essayer et vous faire savoir. Merci – Pietro