These are chat archives for cherrypy/cherrypy

28th
May 2017
mbarkhau
@mbarkhau
May 28 2017 12:12

Hi, I'm trying to shutdown a cheroot server, but it keeps accepting new requests and doesn't shut down, even after I've called server.stop().

I've played around with shutdown_timeout and accepted_queue_timeout but it doesn't seem to help. Only after new requests have stopped for a few seconds does the server shut down.

Is there a way to non gracefully shut down the server, without killing the whole process or thread?

mbarkhau
@mbarkhau
May 28 2017 14:09
@jaraco I've been looking at server.py and threadpool.py trying to figure out what's happening. I think this must be related to existing connections (using keepalive) causing their threads to stay alive.
Jason R. Coombs
@jaraco
May 28 2017 17:35
@mbarkhau: That sounds plausible if not likely. Thinking about keepalive connections, I’m not sure what is the appropriate thing for an HTTP server to do when a shutdown is requested while connections are open for keepalive.
There’s some discussion of Node.js having a similar issue here - nodejs/node#2642
Jason R. Coombs
@jaraco
May 28 2017 17:53
So there are a few concerns at play. The first concern, setting connections to disconnect (and not leave connections open) when shutting down, seems like an obvious beneficial behavior.
Jason R. Coombs
@jaraco
May 28 2017 17:58
More difficult, however, might be dealing with idle keep-alive connections. Those will likely be more difficult to manage, as you might need to deal with race conditions, timeouts, and other factors.
Jason R. Coombs
@jaraco
May 28 2017 18:06
I don’t disagree it would be worthwhile to improve the behavior in these conditions. I welcome help. Please file tickets or draft a change to implement a better functionality.
mbarkhau
@mbarkhau
May 28 2017 18:19
ok, thanks for your response and indeed this seems to be the issue
unfortunately my use case has an easy work around (at least for now), which is to simply send Connection: close
so at least for now i don't think I can help with any improvements
i guess i can open a ticket if you think that makes sense
of course my "solution" assumes the client is well behaved, but i think that's a safe bet for me