Ora nel sedano 4.1 si può risolvere il problema che il codice (il modo più semplice):
import celeryconfig
from celery import Celery
app = Celery()
app.config_from_object(celeryconfig)
Per esempio piccolo celeryconfig.py:
anche modo molto semplice:
from celery import Celery
app = Celery('tasks')
app.conf.update(
result_expires=60,
task_acks_late=True,
broker_url='pyamqp://',
result_backend='redis://localhost'
)
o utilizzando una classe di configurazione/oggetto:
from celery import Celery
app = Celery()
class Config:
enable_utc = True
timezone = 'Europe/London'
app.config_from_object(Config)
# or using the fully qualified name of the object:
# app.config_from_object('module:Config')
O come è stato menzionato impostando CELERY_CONFIG_MODULE
import os
from celery import Celery
#: Set default configuration module name
os.environ.setdefault('CELERY_CONFIG_MODULE', 'celeryconfig')
app = Celery()
app.config_from_envvar('CELERY_CONFIG_MODULE')
Vedi anche:
fonte
2016-11-27 16:41:12
Domanda stupida ... (perché ho fatto questo) quando pitone esegue è in esecuzione la versione corretta. Ho lavorato su sistemi con 2 versioni di Python ... non chiedere. –