SocketServer and Ctrl-C on Windows
p.f.moore at gmail.com
Mon Apr 3 09:56:21 EDT 2017
On Monday, 3 April 2017 14:20:43 UTC+1, Paul Moore wrote:
> On Monday, 3 April 2017 14:00:18 UTC+1, eryk sun wrote:
> > It should service the request and return to the serve_forever() loop.
> > Do you see a line logged for each request, like "[IP] - - [date] "GET
> > ..."?
> Yes, I see that and the page is served.
> >py .\example.py
> Serving HTTP on port 8000...
> 127.0.0.1 - - [03/Apr/2017 13:25:34] "GET / HTTP/1.1" 200 5470
> 127.0.0.1 - - [03/Apr/2017 13:25:34] "GET /favicon.ico HTTP/1.1" 200 5438
> But if I press Ctrl-C at this point, nothing happens. Even if I press Ctrl-C multiple times.
Hmm, looks like sometimes it works. I wonder if the browser is holding open the page request somehow. That seems unlikely as HTTP is supposed to be stateless.
I guess this isn't worth worrying about. It seems like it's only an occasional problem, and I have a workaround (Ctrl-Break) anyway.
More information about the Python-list