This repository was archived by the owner on Mar 24, 2025. It is now read-only.
Prevent GreenletExit exceptions (and improve shutdown time) when shutting down with active keepalive connections #1009
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Internal ticket: SVF-438
This fixes an issue where a Baseplate WSGI server in shutdown doesn't proactively close existing "keepalive" connections and continues to process requests from them. This causes two issues:
GreenletExit
if the server'sstop_time
is reached.This fix causes gevent to close connections once a server begins graceful shutdown (i.e. once
server.stop()
is called). It does this by adding theConnection: close
header on responses and by closing connections in the pool.Commentary
There doesn't appear to be an easy way to fix this without subclassing gevent's
WSGIHandler
and/orWSGIServer
classes. These classes are designed to be subclassed according to the documentation, though it would still be better to fix this in gevent.I believe most gevent users don't hit this as it is fairly rare (and not recommended) to use gevent's built-in WSGI server instead of something like gunicorn.
I've emailed the gevent mailing list to ask about this issue. If the reception is positive I'll submit a patch upstream.
Validation
develop
branch).