Невозможно запустить Django Celery после следующей документации - PullRequest
0 голосов
/ 06 мая 2019

Я пытаюсь внедрить сельдерей в текущий проект django 2.Я использую Django 2.13 и сельдерея 4.3.Вот код в init .py:

import os
from celery import Celery

CONFIG_SETTING = 'lp.settings.development_test'
# set the default Django settings module for the 'celery' program.
os.environ.setdefault('DJANGO_SETTINGS_MODULE', CONFIG_SETTING)

app = Celery('myproject')

# Using a string here means the worker doesn't have to serialize
# the configuration object to child processes.
# - namespace='CELERY' means all celery-related configuration keys
#   should have a `CELERY_` prefix.
app.config_from_object('django.conf:settings', namespace='CELERY')

# Load task modules from all registered Django app configs.
app.autodiscover_tasks()


@app.task(bind=True)
def debug_task(self):
    print('hello world')

Вот код в базовых настройках:


CELERY_BROKER_URL = 'amqp://guest:guest@localhost//'

#: Only add pickle to this list if your broker is secured
#: from unwanted access (see userguide/security.html)
CELERY_ACCEPT_CONTENT = ['json']
CELERY_RESULT_BACKEND = 'django-db'
CELERY_TASK_SERIALIZER = 'json'
CELERY_CACHE_BACKEND = 'django-cache'

INSTALLED_APPS = [
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',

     ...

    'django.contrib.auth',
    'django.contrib.admin',
    'django_celery_results',
]

Когда я запускаю

celery -A myproject worker -l info

Я получаю ошибку.Вот полная трассировка стека:


[2019-05-06 16:09:43,658: CRITICAL/MainProcess] Unrecoverable error: TypeError("argument of type 'NoneType' is not iterable")
Traceback (most recent call last):
  File "c:\program files\python37\lib\site-packages\celery\worker\worker.py", line 205, in start
    self.blueprint.start(self)
  File "c:\program files\python37\lib\site-packages\celery\bootsteps.py", line 119, in start
    step.start(parent)
  File "c:\program files\python37\lib\site-packages\celery\bootsteps.py", line 369, in start
    return self.obj.start()
  File "c:\program files\python37\lib\site-packages\celery\concurrency\base.py", line 131, in start
    self.on_start()
  File "c:\program files\python37\lib\site-packages\celery\concurrency\prefork.py", line 112, in on_start
    **self.options)
  File "c:\program files\python37\lib\site-packages\billiard\pool.py", line 1010, in __init__
    self._create_worker_process(i)
  File "c:\program files\python37\lib\site-packages\billiard\pool.py", line 1119, in _create_worker_process
    w.start()
  File "c:\program files\python37\lib\site-packages\billiard\process.py", line 124, in start
    self._popen = self._Popen(self)
  File "c:\program files\python37\lib\site-packages\billiard\context.py", line 383, in _Popen
    return Popen(process_obj)
  File "c:\program files\python37\lib\site-packages\billiard\popen_spawn_win32.py", line 47, in __init__
    spawn._Django_old_layout_hack__save()
  File "c:\program files\python37\lib\site-packages\billiard\spawn.py", line 81, in _Django_old_layout_hack__save
    project_dir = os.path.normpath(_module_parent_dir(project))
  File "c:\program files\python37\lib\site-packages\billiard\spawn.py", line 53, in _module_parent_dir
    dir, filename = os.path.split(_module_dir(mod))
  File "c:\program files\python37\lib\site-packages\billiard\spawn.py", line 60, in _module_dir
    if '__init__.py' in mod.__file__:
TypeError: argument of type 'NoneType' is not iterable

Есть идеи о том, что я делаю неправильно?

RabbitMQ работает как сервис.

Спасибо!

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...