【问题标题】:Recursion issue on Celery example Django app on windowsWindows 上 Celery 示例 Django 应用程序的递归问题
【发布时间】:2016-07-17 02:20:29
【问题描述】:

我在尝试在 Django 上设置 Celery 时遇到问题,我正在使用 django example app

我使用以下命令设置 virtualenv

pip install virtualenv
virtualenv ..\env
call ..\env\Scripts\activate
pip install celery
pip install django

这给了我以下环境

amqp==1.4.9
anyjson==0.3.3
billiard==3.3.0.23
celery==3.1.23
Django==1.9.4
kombu==3.0.35
pytz==2016.3

在尝试通过命令启动 worker 之后

$ celery -A proj worker -l info

我遇到了运行时错误

File "C:\Python27\Lib\functools.py", line 56, in <lambda>
    '__lt__': [('__gt__', lambda self, other: other < self),
  File "C:\Python27\Lib\functools.py", line 56, in <lambda>
    '__lt__': [('__gt__', lambda self, other: other < self),
  File "C:\Python27\Lib\functools.py", line 56, in <lambda>
    '__lt__': [('__gt__', lambda self, other: other < self),
  File "C:\Python27\Lib\functools.py", line 56, in <lambda>
    '__lt__': [('__gt__', lambda self, other: other < self),
  File "C:\Python27\Lib\functools.py", line 56, in <lambda>
    '__lt__': [('__gt__', lambda self, other: other < self),
  File "C:\Python27\Lib\functools.py", line 56, in <lambda>
    '__lt__': [('__gt__', lambda self, other: other < self),
  File "C:\Python27\Lib\functools.py", line 56, in <lambda>
    '__lt__': [('__gt__', lambda self, other: other < self),
  File "C:\Python27\Lib\functools.py", line 56, in <lambda>
    '__lt__': [('__gt__', lambda self, other: other < self),
  File "C:\Python27\Lib\functools.py", line 56, in <lambda>
    '__lt__': [('__gt__', lambda self, other: other < self),
  File "C:\Python27\Lib\functools.py", line 56, in <lambda>
    '__lt__': [('__gt__', lambda self, other: other < self),
  File "C:\Python27\Lib\functools.py", line 56, in <lambda>
    '__lt__': [('__gt__', lambda self, other: other < self),
  File "C:\Python27\Lib\functools.py", line 56, in <lambda>
    '__lt__': [('__gt__', lambda self, other: other < self),
  File "C:\Python27\Lib\functools.py", line 56, in <lambda>
    '__lt__': [('__gt__', lambda self, other: other < self),
  File "C:\Python27\Lib\functools.py", line 56, in <lambda>
    '__lt__': [('__gt__', lambda self, other: other < self),
  File "C:\Python27\Lib\functools.py", line 56, in <lambda>
    '__lt__': [('__gt__', lambda self, other: other < self),
  File "C:\Python27\Lib\functools.py", line 56, in <lambda>
    '__lt__': [('__gt__', lambda self, other: other < self),
  File "C:\Python27\Lib\functools.py", line 56, in <lambda>
    '__lt__': [('__gt__', lambda self, other: other < self),
  File "C:\Python27\Lib\functools.py", line 56, in <lambda>
    '__lt__': [('__gt__', lambda self, other: other < self),
  File "C:\Python27\Lib\functools.py", line 56, in <lambda>
    '__lt__': [('__gt__', lambda self, other: other < self),
  File "C:\Python27\Lib\functools.py", line 56, in <lambda>
    '__lt__': [('__gt__', lambda self, other: other < self),
  File "C:\Python27\Lib\functools.py", line 56, in <lambda>
    '__lt__': [('__gt__', lambda self, other: other < self),
  File "C:\Python27\Lib\functools.py", line 56, in <lambda>
    '__lt__': [('__gt__', lambda self, other: other < self),
  File "C:\Python27\Lib\functools.py", line 56, in <lambda>
    '__lt__': [('__gt__', lambda self, other: other < self),
  File "C:\Python27\Lib\functools.py", line 56, in <lambda>
    '__lt__': [('__gt__', lambda self, other: other < self),
  File "C:\Python27\Lib\functools.py", line 56, in <lambda>
    '__lt__': [('__gt__', lambda self, other: other < self),
  File "C:\Python27\Lib\functools.py", line 56, in <lambda>
    '__lt__': [('__gt__', lambda self, other: other < self),
  File "C:\Python27\Lib\functools.py", line 56, in <lambda>
    '__lt__': [('__gt__', lambda self, other: other < self),
  File "C:\Python27\Lib\functools.py", line 56, in <lambda>
    '__lt__': [('__gt__', lambda self, other: other < self),
  File "C:\Python27\Lib\functools.py", line 56, in <lambda>
    '__lt__': [('__gt__', lambda self, other: other < self),
  File "C:\Python27\Lib\functools.py", line 56, in <lambda>
    '__lt__': [('__gt__', lambda self, other: other < self),
  File "C:\Python27\Lib\functools.py", line 56, in <lambda>
    '__lt__': [('__gt__', lambda self, other: other < self),
  File "C:\Python27\Lib\functools.py", line 56, in <lambda>
    '__lt__': [('__gt__', lambda self, other: other < self),
  File "C:\Python27\Lib\functools.py", line 56, in <lambda>
    '__lt__': [('__gt__', lambda self, other: other < self),
  File "C:\Python27\Lib\functools.py", line 56, in <lambda>
    '__lt__': [('__gt__', lambda self, other: other < self),
  File "C:\Python27\Lib\functools.py", line 56, in <lambda>
    '__lt__': [('__gt__', lambda self, other: other < self),
  File "C:\Python27\Lib\functools.py", line 56, in <lambda>
    '__lt__': [('__gt__', lambda self, other: other < self),
  File "C:\Python27\Lib\functools.py", line 56, in <lambda>
    '__lt__': [('__gt__', lambda self, other: other < self),
  File "C:\Python27\Lib\functools.py", line 56, in <lambda>
    '__lt__': [('__gt__', lambda self, other: other < self),
RuntimeError: maximum recursion depth exceeded while calling a Python object

你知道我做错了什么吗?

【问题讨论】:

  • 请参考这个答案-stackoverflow.com/a/21834988/5121725
  • @RA123 感谢您的快速回答,它为我指明了正确的方向,我有已过时的 python 2.7.2 我将其更新为目前最新的 python 2.7.11,它可以工作。如果您可以创建答案,我会接受它,因为您是第一个谢谢。

标签: python django python-2.7 celery


【解决方案1】:

问题出在 functools.py 文件中。
要解决此问题,请在文件 functools.py 中替换转换字典(大约在 python\Lib\functools.py 中的第 56 行):

convert = {
'__lt__': [('__gt__', lambda self, other: other < self),
           ('__le__', lambda self, other: not other < self),
           ('__ge__', lambda self, other: not self < other)],
'__le__': [('__ge__', lambda self, other: other <= self),
           ('__lt__', lambda self, other: not other <= self),
           ('__gt__', lambda self, other: not self <= other)],
'__gt__': [('__lt__', lambda self, other: other > self),
           ('__ge__', lambda self, other: not other > self),
           ('__le__', lambda self, other: not self > other)],
'__ge__': [('__le__', lambda self, other: other >= self),
           ('__gt__', lambda self, other: not other >= self),
           ('__lt__', lambda self, other: not self >= other)]
}

到那个值

convert = {
'__lt__': [('__gt__', lambda self, other: not (self < other or self == other)),
           ('__le__', lambda self, other: self < other or self == other),
           ('__ge__', lambda self, other: not self < other)],
'__le__': [('__ge__', lambda self, other: not self <= other or self == other),
           ('__lt__', lambda self, other: self <= other and not self == other),
           ('__gt__', lambda self, other: not self <= other)],
'__gt__': [('__lt__', lambda self, other: not (self > other or self == other)),
           ('__ge__', lambda self, other: self > other or self == other),
           ('__le__', lambda self, other: not self > other)],
'__ge__': [('__le__', lambda self, other: (not self >= other) or self == other),
           ('__gt__', lambda self, other: self >= other and not self == other),
           ('__lt__', lambda self, other: not self >= other)]
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-06-20
    • 2014-04-05
    • 1970-01-01
    • 1970-01-01
    • 2016-09-06
    • 1970-01-01
    • 1970-01-01
    • 2018-09-24
    相关资源
    最近更新 更多