Gunicorn ImportError:无法从 docker 中的“eventlet.wsgi”导入名称“ALREADY_HANDLED”

问题描述

我有一个在 docker 中使用 gunicorn(eventlet worker)运行烧瓶的工作代码。它也在生产中工作,但在我的机器上,它开始这样做。我在谷歌上找不到关于这件事的任何信息。可能是什么问题?

Error: class uri 'eventlet' invalid or not found:
web_1       |
web_1       | [Traceback (most recent call last):
web_1       |   File "/root/.local/lib/python3.7/site-packages/gunicorn/util.py",line 99,in load_class
web_1       |     mod = importlib.import_module('.'.join(components))
web_1       |   File "/usr/local/lib/python3.7/importlib/__init__.py",line 127,in import_module
web_1       |     return _bootstrap._gcd_import(name[level:],package,level)
web_1       |   File "<frozen importlib._bootstrap>",line 1006,in _gcd_import
web_1       |   File "<frozen importlib._bootstrap>",line 983,in _find_and_load
web_1       |   File "<frozen importlib._bootstrap>",line 967,in _find_and_load_unlocked
web_1       |   File "<frozen importlib._bootstrap>",line 677,in _load_unlocked
web_1       |   File "<frozen importlib._bootstrap_external>",line 728,in exec_module
web_1       |   File "<frozen importlib._bootstrap>",line 219,in _call_with_frames_removed
web_1       |   File "/root/.local/lib/python3.7/site-packages/gunicorn/workers/geventlet.py",line 20,in <module>
web_1       |     from eventlet.wsgi import ALREADY_HANDLED as EVENTLET_ALREADY_HANDLED
web_1       | ImportError: cannot import name 'ALREADY_HANDLED' from 'eventlet.wsgi' (/root/.local/lib/python3.7/site-packages/eventlet/wsgi.py)
web_1       | ]

解决方法

安装旧版本的 eventlet 解决了这个问题:pip install eventlet==0.30.2

,

最近 eventlet

似乎发生了变化

有关示例补丁和潜在发布版本,请参阅此 PR:https://github.com/benoitc/gunicorn/pull/2581

Eventlet 0.30.3+ 移除了破坏公共 API 的 wsgi.ALREADY_HANDLED 只是一个补丁版本增加。对不起。

问题与 ALREADY_HANDLED:eventlet/eventlet#543 解决方案 WSGI_LOCAL: eventlet/eventlet#544

如果使用websockets,推荐使用eventlet>=0.31.0, 因为旧版本容易受到 DoS 攻击。 GHSA-9p9m-jm8w-94p2

CI 在 pylint 检查中失败,我没有接触过。