Skip to content

eventlet.websocket is not always used from eventlet.wsgi, so do not assume eventlet.set_idle exists#949

Merged
4383 merged 2 commits intoeventlet:masterfrom
dhdaines:issue-946
Mar 29, 2024
Merged

eventlet.websocket is not always used from eventlet.wsgi, so do not assume eventlet.set_idle exists#949
4383 merged 2 commits intoeventlet:masterfrom
dhdaines:issue-946

Conversation

@dhdaines
Copy link
Copy Markdown
Contributor

In the case where Eventlet's WebSocket implementation is used, for instance, in a Gunicorn worker, it ends up being the case that WebSocketWSGI is not running under an Eventlet server, and thus shouldn't assume that the environment contains eventlet.set_idle (which is an implementation detail of the Eventlet server and thus quite meaniningless).

This is notably the case when using Flask-SocketIO with Gunicorn as suggested in the documentation: https://flask-socketio.readthedocs.io/en/latest/deployment.html#gunicorn-web-server

It seems quite safe to just avoid trying to call it in this case. If, for instance, the engineio wrapper (https://github.com/miguelgrinberg/python-engineio/blob/main/src/engineio/async_drivers/eventlet.py#L39) wishes to provide eventlet.set_idle for some reason, then it could do so.

Fixes #946

@dhdaines
Copy link
Copy Markdown
Contributor Author

Note that I don't know of any good way to test this inside Eventlet... it seems fiendishly complicated to mock a Gunicorn worker, so that's left as an exercise to the maintainer :)

@4383 4383 requested a review from tipabu March 26, 2024 14:16
Copy link
Copy Markdown
Member

@4383 4383 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concerning myself, this patch LGTM.

I'd appreciate to have a secondary opinion from Tim.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 26, 2024

Codecov Report

Attention: Patch coverage is 50.00000% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 56%. Comparing base (80f3936) to head (2082573).

Files Patch % Lines
eventlet/websocket.py 50% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@          Coverage Diff          @@
##           master   #949   +/-   ##
=====================================
- Coverage      56%    56%   -1%     
=====================================
  Files          89     89           
  Lines        9766   9767    +1     
  Branches     1818   1819    +1     
=====================================
  Hits         5475   5475           
- Misses       3920   3921    +1     
  Partials      371    371           
Flag Coverage Δ
ipv6 23% <0%> (-1%) ⬇️
py310asyncio 52% <50%> (-1%) ⬇️
py310epolls 53% <50%> (-1%) ⬇️
py310poll 53% <50%> (-1%) ⬇️
py310selects 53% <50%> (-1%) ⬇️
py311asyncio 52% <50%> (-1%) ⬇️
py311epolls 53% <50%> (-1%) ⬇️
py312asyncio 50% <50%> (-1%) ⬇️
py312epolls 51% <50%> (-1%) ⬇️
py37asyncio 50% <50%> (-1%) ⬇️
py37epolls 51% <50%> (-1%) ⬇️
py38asyncio 51% <50%> (-1%) ⬇️
py38epolls 53% <50%> (-1%) ⬇️
py38openssl 51% <50%> (-1%) ⬇️
py38poll 53% <50%> (-1%) ⬇️
py38selects 53% <50%> (+<1%) ⬆️
py39asyncio 51% <50%> (-1%) ⬇️
py39dnspython1 51% <50%> (-1%) ⬇️
py39epolls 53% <50%> (+<1%) ⬆️
py39poll 53% <50%> (-1%) ⬇️
py39selects 52% <50%> (+<1%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@4383
Copy link
Copy Markdown
Member

4383 commented Mar 29, 2024

Well, I think these changes are well isolated and should not trigger side effects. Let's go ahead to fix the latest release.
I'm going to prepare a new release.

Thanks @dhdaines for your patch,for your time and for the interesting discussion. Much appreciated.

@4383 4383 merged commit c0cb04d into eventlet:master Mar 29, 2024
@4383 4383 mentioned this pull request Mar 29, 2024
openstack-mirroring pushed a commit to openstack/requirements that referenced this pull request Apr 5, 2024
It will allow us to benefit from several recent fixes
related to the new asyncio hub.

We started to implement some devstack integrations
with the new eventlet asyncio hub [1], so it is worth
using a version that contains useful fixes.
See https://review.opendev.org/c/openstack/devstack/+/914108

Also this patch propose to blacklist version 0.36.0 which is
buggy version in some wsgi context. 0.36.1 fix that wsgi problem.
For further details see:

- eventlet/eventlet#946
- eventlet/eventlet#949

Change-Id: I2add78de0e3d2f439964afa0d0c9d854a52b5f7f
openstack-mirroring pushed a commit to openstack/openstack that referenced this pull request Apr 5, 2024
* Update requirements from branch 'master'
  to 4ba203d335842ba76005e0ab3a395c6b1f5853c4
  - Merge "bump eventlet to the latest version"
  - bump eventlet to the latest version
    
    It will allow us to benefit from several recent fixes
    related to the new asyncio hub.
    
    We started to implement some devstack integrations
    with the new eventlet asyncio hub [1], so it is worth
    using a version that contains useful fixes.
    See https://review.opendev.org/c/openstack/devstack/+/914108
    
    Also this patch propose to blacklist version 0.36.0 which is
    buggy version in some wsgi context. 0.36.1 fix that wsgi problem.
    For further details see:
    
    - eventlet/eventlet#946
    - eventlet/eventlet#949
    
    Change-Id: I2add78de0e3d2f439964afa0d0c9d854a52b5f7f
clrpackages pushed a commit to clearlinux-pkgs/pypi-eventlet that referenced this pull request Jul 10, 2024
…rsion 0.36.1

0.36.1
======

* [fix] eventlet.websocket is not always used from eventlet.wsgi, so do not assume eventlet.set_idle exists eventlet/eventlet#949

0.36.0
======

* [fix] Make sure asyncio hub doesn't use greendns for asyncio DNS APIs eventlet/eventlet#938
* [fix] Make asyncio.to_thread work with the same semantics as normal asyncio eventlet/eventlet#930
* [fix] Refactor congruence checks based on assert at runtime eventlet/eventlet#932
* [tests] Run tests on macOS in CI, and some fixes to get it in reasonable state (#list eventlet/eventlet#934
* [fix] Fix wsgi.server shutdown for in-flight requests eventlet/eventlet#912
* [feature] Add debug convenience helpers - asyncio, threads eventlet/eventlet#925
* [fix] Handle errors better. eventlet/eventlet#923

(NEWS truncated at 15 lines)

CVEs fixed in this build:
CVE-2023-29483
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

eventlet 0.36.0 incompatible with flask-socketio running under gunicorn

2 participants