SocketServer and Ctrl-C on Windows

Paul Moore p.f.moore at
Mon Apr 3 08:34:56 EDT 2017

On Monday, 3 April 2017 13:23:11 UTC+1, eryk sun  wrote:
> It works for me when run from a command prompt in Windows 10.
> serve_forever() uses select() with a timeout of 0.5s, so it doesn't
> block the main thread.

Odd. For me, it doesn't work (Windows 7, but I can't see why that would affect it).

Having investigated a bit more, it seems like if I just start the server then hit Ctrl-C it shuts down fine. But if I start the server, then I navigate to http://localhost:8000 in my browser, and *then* hit Ctrl-C, the server just continues running.

So I don't know if it's something to do with having handled a request? I have a vague recollection that it's to do with threading - maybe the exception being delivered to the wrong thread? Or a non-daemon thread being left active?

Thanks for checking for me, though.

More information about the Python-list mailing list