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

Add WebSocketRequestCompleted exception for normal WebSocket closures #73

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

cafedeflore
Copy link

In relation to issue #64, under the configuration of running Flask with Gunicorn and Gevent, a StopIteration exception is not captured by Flask, but it enters the finally clause. Consequently, this exception is not caught higher up by Gunicorn's StopIteration handler. Referencing this section of Flask's codebase: Flask on GitHub. When error capturing tools like Sentry are used, this leads to the reporting of the exception. Is it possible to define this exception specifically, so that Sentry can easily ignore it, and to distinguish it from a normal StopIteration?

@miguelgrinberg
Copy link
Owner

miguelgrinberg commented Dec 15, 2023

I don't understand how this works. Gunicorn expects StopIteration to be raised as a signal that the request should be ended. You have changed the exception to a different one that nobody handles. To me this looks like it breaks all usages of gunicorn except the one you are interested in, which we already know that it is broken in gunicorn and not here.

The correct solution here is to make the gevent worker in gunicorn use the StopIteration exception, in the same way the threaded and eventlet workers do.

As I mentioned in #64, if you are interested in using gevent you can use it directly instead of through Gunicorn and you will not see this, as the StopIteration trick only applies to Gunicorn.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants