windows 上 Celery 示例 Django 应用程序的递归问题

Recursion issue on Celery example Django app on windows

我在尝试在我使用的 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

你知道我做错了什么吗?

问题出在 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)]
}