Eventlet 0.31.0 causes runtime exception in gunicorn
hughsie opened this issue · comments
Update: This should apparently be fixed by upgrading to latest gunicorn.
All my webapps are failing to startup with:
Error: class uri 'eventlet' invalid or not found:
[Traceback (most recent call last):
File "/app/venv/lib64/python3.6/site-packages/gunicorn/util.py", line 99, in load_class
mod = importlib.import_module('.'.join(components))
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 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/app/venv/lib64/python3.6/site-packages/gunicorn/workers/geventlet.py", line 20, in <module>
from eventlet.wsgi import ALREADY_HANDLED as EVENTLET_ALREADY_HANDLED
ImportError: cannot import name 'ALREADY_HANDLED'
Pinning to eventlet==0.30.2 "fixes" the issue.
I have the same issue with 0.31.0.
Pinning to eventlet==0.30.2 "fixed" the issue for me too.
Same here, was running pip install gunicorn[eventlet]==19.9.0
to install gunicorn and eventlet in our docker environment.
Out production server went down and is still down, trying the above by installing gunicorn and eventlet separately with the specified versions.
@SoSDylan
pip install gunicorn==20.1.0 eventlet==0.30.2
is working for me. Try this maybe.
@Mark7888
Thank you! That worked, we had about 30 companies that were on our backs about out site being down 😅
Problem
Eventlet 0.30.3 removed eventlet.wsgi.ALREADY_HANDLED
which is used by gunicorn
Solution
Proper fix - merged, not released in upstream benoitc/gunicorn#2581
Workaround
Pin eventlet==0.30.2
is correct workaround for now.
If you use websockets, please upgrade eventlet>=0.31.0
ASAP, there is moderate security fix. GHSA-9p9m-jm8w-94p2
Note to maintainers: please remove workaround when patch is accepted in gunicorn.
Really glad I found this workaround. Version 0.31.0
was causing a Heroku-hosted Flask app to crash, but downgrading to 0.30.2
got it working again.
Thanks, this workaround is helpful
Is this workaround supposed to work with Python 3.10?
I'm running gunicorn==20.1.0 and eventlet==0.30.2 on Python 3.10.6 and getting this error:
Error: class uri 'eventlet' invalid or not found:
[Traceback (most recent call last):
File "/var/www/html/python-tests/pronunciation-demo/venv/lib/python3.10/site-packages/gunicorn/util.py", line 99, in load_class
mod = importlib.import_module('.'.join(components))
File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/var/www/html/python-tests/pronunciation-demo/venv/lib/python3.10/site-packages/gunicorn/workers/geventlet.py", line 10, in <module>
import eventlet
File "/var/www/html/python-tests/pronunciation-demo/venv/lib/python3.10/site-packages/eventlet/__init__.py", line 17, in <module>
from eventlet import convenience
File "/var/www/html/python-tests/pronunciation-demo/venv/lib/python3.10/site-packages/eventlet/convenience.py", line 7, in <module>
from eventlet.green import socket
File "/var/www/html/python-tests/pronunciation-demo/venv/lib/python3.10/site-packages/eventlet/green/socket.py", line 4, in <module>
__import__('eventlet.green._socket_nodns')
File "/var/www/html/python-tests/pronunciation-demo/venv/lib/python3.10/site-packages/eventlet/green/_socket_nodns.py", line 11, in <module>
from eventlet import greenio
File "/var/www/html/python-tests/pronunciation-demo/venv/lib/python3.10/site-packages/eventlet/greenio/__init__.py", line 3, in <module>
from eventlet.greenio.base import * # noqa
File "/var/www/html/python-tests/pronunciation-demo/venv/lib/python3.10/site-packages/eventlet/greenio/base.py", line 32, in <module>
socket_timeout = eventlet.timeout.wrap_is_timeout(socket.timeout)
File "/var/www/html/python-tests/pronunciation-demo/venv/lib/python3.10/site-packages/eventlet/timeout.py", line 166, in wrap_is_timeout
base.is_timeout = property(lambda _: True)
TypeError: cannot set 'is_timeout' attribute of immutable type 'TimeoutError'
]
Just wanted to confirm that eventlet==0.30.2 with gunicorn==20.1.0 running on Python 3.10.6 does crash, with the TimeoutError mentioned in my previous post.
Confirming that things work fine with Python 3.9.15.
Python 3.10 has been out for over a year and is default on, say, Ubuntu 22.
Is this workaround supposed to work with Python 3.10?
No, older eventlet version from workaround does not support Python 3.10. This issue/thread/workaround is not related to Python 3.10 support in any way.
If you need to run gunicorn with eventlet, use gunicorn master or eventlet 0.30.2. Latter doesn't support 3.10.
I have successfully run simplest WSGI app using eventlet 0.33.2, gunicorn master and Python 3.10.
Sorry for inconvenience.
gunicorn fixed this, sounds like.