Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Mar 29, 2024

Conversation

dhdaines
Copy link
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
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
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.

Copy link

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
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
27 of 28 checks passed
@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
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