@Yevgeni

Проблема при запуске celery совместно с Flask. В чем проблема?

Мое приложение flask:
from flask import Flask
from celery import Celery


app = Flask(__name__)
app.debug = True
app.config['CELERY_BROKER_URL'] = 'mongodb://логин:пароль@ds243041.mlab.com:43041/flaskmongodb'
app.config['CELERY_RESULT_BACKEND'] = 'mongodb://логин:пароль@ds243041.mlab.com:43041/flaskmongodb'

celery = Celery(app.name, broker=app.config['CELERY_BROKER_URL'])
celery.conf.update(app.config

@app.route('/run_Task')
def run_celery_task():
    my_task.delay()
    return 'Задача запущена'


@celery.task(name='app.my_task')
def my_task():
    return 'task completed'

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


В консоли я прописываю
celery -A run_flask.celery worker --loglevel=info

А на выходе ошибка:
spoiler


Process SpawnPoolWorker-4:
Traceback (most recent call last):
File "c:\users\yevge\appdata\local\programs\python\python36-32\lib\site-packages\kombu\utils\objects.py", line 42, in __get__
return obj.__dict__[self.__name__]
KeyError: 'default_modules'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "c:\users\yevge\appdata\local\programs\python\python36-32\lib\site-packages\kombu\utils\objects.py", line 42, in __get__
return obj.__dict__[self.__name__]
KeyError: 'data'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "c:\users\yevge\appdata\local\programs\python\python36-32\lib\site-packages\billiard\process.py", line 327, in _bootstrap
self.run()
File "c:\users\yevge\appdata\local\programs\python\python36-32\lib\site-packages\billiard\process.py", line 114, in run
self._target(*self._args, **self._kwargs)
File "c:\users\yevge\appdata\local\programs\python\python36-32\lib\site-packages\billiard\pool.py", line 286, in __call__
self.after_fork()
File "c:\users\yevge\appdata\local\programs\python\python36-32\lib\site-packages\billiard\pool.py", line 395, in after_fork
self.initializer(*self.initargs)
File "c:\users\yevge\appdata\local\programs\python\python36-32\lib\site-packages\celery\concurrency\prefork.py", line 55, in process_initializer
app.loader.init_worker()
File "c:\users\yevge\appdata\local\programs\python\python36-32\lib\site-packages\celery\loaders\base.py", line 114, in init_worker
self.import_default_modules()
File "c:\users\yevge\appdata\local\programs\python\python36-32\lib\site-packages\celery\loaders\base.py", line 109, in import_default_modules
return [self.import_task_module(m) for m in self.default_modules]
File "c:\users\yevge\appdata\local\programs\python\python36-32\lib\site-packages\kombu\utils\objects.py", line 44, in __get__
value = obj.__dict__[self.__name__] = self.__get(obj)
File "c:\users\yevge\appdata\local\programs\python\python36-32\lib\site-packages\celery\loaders\base.py", line 227, in default_modules
tuple(maybe_list(self.app.conf.imports)) +
File "c:\users\yevge\appdata\local\programs\python\python36-32\lib\site-packages\celery\utils\collections.py", line 126, in __getattr__
return self[k]
File "c:\users\yevge\appdata\local\programs\python\python36-32\lib\site-packages\celery\utils\collections.py", line 429, in __getitem__
return getitem(k)
File "c:\users\yevge\appdata\local\programs\python\python36-32\lib\site-packages\celery\utils\collections.py", line 278, in __getitem__
return mapping[_key]
File "c:\users\yevge\appdata\local\programs\python\python36-32\lib\collections\__init__.py", line 987, in __getitem__
if key in self.data:
File "c:\users\yevge\appdata\local\programs\python\python36-32\lib\site-packages\kombu\utils\objects.py", line 44, in __get__
value = obj.__dict__[self.__name__] = self.__get(obj)
File "c:\users\yevge\appdata\local\programs\python\python36-32\lib\site-packages\celery\app\base.py", line 141, in data
return self.callback()
File "c:\users\yevge\appdata\local\programs\python\python36-32\lib\site-packages\celery\app\base.py", line 924, in _finalize_pending_conf
conf = self._conf = self._load_config()
File "c:\users\yevge\appdata\local\programs\python\python36-32\lib\site-packages\celery\app\base.py", line 938, in _load_config
ignore_keys=self._preconf_set_by_auto, prefix=self.namespace,
File "c:\users\yevge\appdata\local\programs\python\python36-32\lib\site-packages\celery\app\utils.py", line 255, in detect_settings
for key in sorted(really_left)
celery.exceptions.ImproperlyConfigured:

Cannot mix new setting names with old setting names, please
rename the following settings to use the old format:

include -> CELERY_INCLUDE

Or change all of the settings to use the new format :)

  • Вопрос задан
  • 308 просмотров
Пригласить эксперта
Ответы на вопрос 2
dimonchik2013
@dimonchik2013
non progredi est regredi
Cannot mix new setting names with old setting name...

в Селери формат менялся, нужно чтобьы все параметры назывались или по старому, или по-новому
Ответ написан
@Vladimyr1991
Младший бекенд разработчик
celery.conf.update(app.config - скобка пропущена?
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы