-
Notifications
You must be signed in to change notification settings - Fork 332
Keep-alive WSGI server connections prevent shutdown #188
Description
In the eventlet.wsgi module, following the 1c30e9b changeset, the WSGI server function always waits for all threads to terminate before returning.
This was a useful change as it ensures a more graceful cleanup (although might have undesirable effects when used with the custom_pool parameter). However, if the server supports keepalive connections, these will cause the GreenPool.waitall() call to hang until all connections have terminated.
There ought to be some mechanism to ensure that in progress requests are serviced and cleanly disconnected, but that persistent connections are 'snipped' between requests. The appropriate point at which to split this is https://github.com/eventlet/eventlet/blob/master/eventlet/wsgi.py#L276 (as connections may already be waiting).
Possible solution (based on little experience with eventlet) might take the form of a eventlet.green.select over self.rfile and a GreenPipe passed in from the server. The GreenPipe could be signalled on shutdown by the server, triggering the connection to wake up and disconnect.