错误执行Celery-Django-CentOS

时间:2018-06-21 15:26:13

标签: python django celery python-3.6 django-celery

我在CentOS服务器上部署了我的网站,但出现了一个错误,该错误在帮助论坛上尚未出现。

我的配置:

Python = 3.6.5
Django = 2.0.6
Kombu = 4.2.1
celery = 4.2.0

settings.py

只有芹菜的一部分

# Configure Celery
BROKER_URL = "pyamqp://"
BROKER_POOL_LIMIT = None

CELERY_RESULT_BACKEND = "redis://localhost"

init .py

MYSITE/MYSITE中的初始化文件。 我将DEBUG设置放在这里,因为在我的产品环境中,MariaDB不支持MYSQLdb。

from __future__ import absolute_import, unicode_literals

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

__all__ = ['celery_app']


if DEBUG == False:
    import pymysql
    pymysql.install_as_MySQLdb()

celery_settings.py

MYSITE/MYSITE中的芹菜设置文件。

from __future__ import absolute_import, unicode_literals
import os
from celery import Celery

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

app = Celery('MYSITE')

# 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()

# define timezone
app.conf.timezone = 'Europe/Paris'


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

错误

(MYENV-python3.6) [XXXX@XXXXX MYSITE]$ celery -A     MYSITE.celery_settings worker -l info --autoscale 12
Traceback (most recent call last):
  File "/MYENVPATH/lib64/python3.6/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 "/MYENVPATH/bin/celery", line 11, in <module>
    sys.exit(main())
  File "/MYENVPATH/lib64/python3.6/site-packages/celery/__main__.py", line 16, in main
    _main()
  File "MYENVPATH/lib64/python3.6/site-packages/celery/bin/celery.py", line 322, in main
    cmd.execute_from_commandline(argv)
  File "/MYENVPATH/lib64/python3.6/site-packages/celery/bin/celery.py", line 496, in execute_from_commandline
    super(CeleryCommand, self).execute_from_commandline(argv)))
  File "/MYENVPATH/lib64/python3.6/site-packages/celery/bin/base.py", line 275, in execute_from_commandline
    return self.handle_argv(self.prog_name, argv[1:])
  File "/MYENVPATH/lib64/python3.6/site-packages/celery/bin/celery.py", line 488, in handle_argv
    return self.execute(command, argv)
  File "/MYENVPATH/lib64/python3.6/site-packages/celery/bin/celery.py", line 420, in execute
    ).run_from_argv(self.prog_name, argv[1:], command=argv[0])
  File "/MYENVPATH/lib64/python3.6/site-packages/celery/bin/worker.py", line 221, in run_from_argv
    *self.parse_options(prog_name, argv, command))
  File "/MYENVPATH/lib64/python3.6/site-packages/celery/bin/base.py", line 398, in parse_options
    self.parser = self.create_parser(prog_name, command)
  File "/MYENVPATH/lib64/python3.6/site-packages/celery/bin/base.py", line 414, in create_parser
    self.add_arguments(parser)
  File "/MYENVPATH/lib64/python3.6/site-packages/celery/bin/worker.py", line 277, in add_arguments
    default=conf.worker_state_db,
  File "/MYENVPATH/lib64/python3.6/site-packages/celery/utils/collections.py", line 126, in __getattr__
    return self[k]

AND VERY A LOT OF TIME THIS PREVIOUS ERROR

  File "/usr/lib64/python3.6/collections/__init__.py", line 987, in __getitem__
    if key in self.data:
  File "/MYENVPATH/lib64/python3.6/site-packages/kombu/utils/objects.py", line 44, in __get__
    value = obj.__dict__[self.__name__] = self.__get(obj)
  File "/MYENVPATH/lib64/python3.6/site-packages/celery/app/base.py", line 141, in data
    return self.callback()
  File "/MYENVPATH/lib64/python3.6/site-packages/celery/app/base.py", line 924, in _finalize_pending_conf
    conf = self._conf = self._load_config()
  File "/MYENVPATH/lib64/python3.6/site-packages/celery/app/base.py", line 934, in _load_config
    self.loader.config_from_object(self._config_source)
  File "/MYENVPATH/lib64/python3.6/site-packages/celery/loaders/base.py", line 126, in config_from_object
    obj = self._smart_import(obj, imp=self.import_from_cwd)
  File "/MYENVPATH/lib64/python3.6/site-packages/celery/loaders/base.py", line 139, in _smart_import
    return symbol_by_name(path, imp=imp)
  File "/MYENVPATH/lib64/python3.6/site-packages/kombu/utils/imports.py", line 56, in symbol_by_name
    module = imp(module_name, package=package, **kwargs)
  File "/MYENVPATH/lib64/python3.6/site-packages/celery/loaders/base.py", line 98, in import_from_cwd
    package=package,
  File "/MYENVPATH/lib64/python3.6/site-packages/celery/utils/imports.py", line 104, in import_from_cwd
    return imp(module, package=package)
  File "/MYENVPATH/lib64/python3.6/site-packages/celery/loaders/base.py", line 92, in import_module
    return importlib.import_module(module, package=package)
  File "/usr/lib64/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 968, in _find_and_load
RecursionError: maximum recursion depth exceeded

如果您需要更多详细信息,请告诉我。

0 个答案:

没有答案