【问题标题】:Current version of celery and django-celery don't seem compatible当前版本的 celery 和 django-celery 似乎不兼容
【发布时间】:2014-02-14 20:17:05
【问题描述】:

所以我目前已经安装了 Celery 3.1.8 (Ciper) 和 Djcelery 3.1.1,但是按照教程操作会导致我的网站崩溃

所以本教程 http://docs.celeryproject.org/en/master/django/first-steps-with-django.html#django-first-steps

我非常关注,但是当我尝试在 settings.py

中使用这一行导入 django-celery
import djcelery

我收到服务器错误。查看它说的错误日志

[Fri Jan 24 00:47:40 2014] [error] [client 24.61.15.120] mod_wsgi (pid=32567): Exception occurred processing WSGI script '/srv/www/site/app1/wsgi_app1.py'.
[Fri Jan 24 00:47:40 2014] [error] [client 24.61.15.120] Traceback (most recent call last):
[Fri Jan 24 00:47:40 2014] [error] [client 24.61.15.120]   File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/wsgi_app1.py", line 236, in __call__
[Fri Jan 24 00:47:40 2014] [error] [client 24.61.15.120]     self.load_middleware()
[Fri Jan 24 00:47:40 2014] [error] [client 24.61.15.120]   File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 45, in load_middleware
[Fri Jan 24 00:47:40 2014] [error] [client 24.61.15.120]     for middleware_path in settings.MIDDLEWARE_CLASSES:
[Fri Jan 24 00:47:40 2014] [error] [client 24.61.15.120]   File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 52, in __getattr__
[Fri Jan 24 00:47:40 2014] [error] [client 24.61.15.120]     self._setup(name)
[Fri Jan 24 00:47:40 2014] [error] [client 24.61.15.120]   File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 47, in _setup
[Fri Jan 24 00:47:40 2014] [error] [client 24.61.15.120]     self._wrapped = Settings(settings_module)
[Fri Jan 24 00:47:40 2014] [error] [client 24.61.15.120]   File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 132, in __init__
[Fri Jan 24 00:47:40 2014] [error] [client 24.61.15.120]     raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))
[Fri Jan 24 00:47:40 2014] [error] [client 24.61.15.120] ImportError: Could not import settings 'site.settings_app1' (Is it on sys.path?): cannot import name Celery
[Fri Jan 24 00:47:41 2014] [error] [client 24.61.15.120] mod_wsgi (pid=32567): Exception occurred processing WSGI script '/srv/www/site/app1/wsgi_app1.py'.
[Fri Jan 24 00:47:41 2014] [error] [client 24.61.15.120] Traceback (most recent call last):
[Fri Jan 24 00:47:41 2014] [error] [client 24.61.15.120]   File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/wsgi_app1.py", line 236, in __call__
[Fri Jan 24 00:47:41 2014] [error] [client 24.61.15.120]     self.load_middleware()
[Fri Jan 24 00:47:41 2014] [error] [client 24.61.15.120]   File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 45, in load_middleware
[Fri Jan 24 00:47:41 2014] [error] [client 24.61.15.120]     for middleware_path in settings.MIDDLEWARE_CLASSES:
[Fri Jan 24 00:47:41 2014] [error] [client 24.61.15.120]   File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 52, in __getattr__
[Fri Jan 24 00:47:41 2014] [error] [client 24.61.15.120]     self._setup(name)
[Fri Jan 24 00:47:41 2014] [error] [client 24.61.15.120]   File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 47, in _setup
[Fri Jan 24 00:47:41 2014] [error] [client 24.61.15.120]     self._wrapped = Settings(settings_module)
[Fri Jan 24 00:47:41 2014] [error] [client 24.61.15.120]   File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 132, in __init__
[Fri Jan 24 00:47:41 2014] [error] [client 24.61.15.120]     raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))
[Fri Jan 24 00:47:41 2014] [error] [client 24.61.15.120] ImportError: Could not import settings 'site.settings_app1' (Is it on sys.path?): cannot import name Celery

我什至不知道如何继续前进。该导入实际上是导致问题的原因,我需要使用 djcelery 来利用 Django 后端的东西

编辑:

我知道大多数事情不需要 djcelery,但在 3.1 的发行说明中它说 http://docs.celeryproject.org/en/master/whatsnew-3.1.html#django-supported-out-of-the-box

有些功能仍然需要 django-celery 库:

    Celery does not implement the Django database or cache result backends.

    Celery does not ship with the database-based periodic task

        scheduler.

我想使用我的数据库作为后端

【问题讨论】:

    标签: python django celery django-celery djcelery


    【解决方案1】:

    嗯,这仍然是一个问题,但我了解到您实际上根本不需要 django-celery 来允许数据库保存,所以我会考虑回答这个问题

    【讨论】:

      猜你喜欢
      • 2017-10-26
      • 2019-11-15
      • 2012-10-06
      • 1970-01-01
      • 2011-07-24
      • 2017-06-11
      • 2011-07-18
      • 2011-07-17
      • 1970-01-01
      相关资源
      最近更新 更多