This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author martin.panter
Recipients martin.panter, mattpr, ned.deily, ronaldoussoren
Date 2017-10-01.00:06:29
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1506816392.73.0.213398074469.issue31639@psf.upfronthosting.co.za>
In-reply-to
Content
The change in handling KeyboardInterrupt was my intention in Issue 23430. I hope it isn’t a problem on its own :)

Running the module with “python -m http.server” uses the HTTPServer class, based on socketserver.TCPServer. This only accepts one connection at a time, and waits for the SimpleHTTPRequestHandler class to finish handling each TCP connection before shutting it down and waiting for the next one. But SimpleHTTPRequestHandler supports persistent HTTP connections, meaning the TCP connection stays open after one HTTP request, ready for another. This prevents the simple TCPServer from accepting new connections.

What is probably happening is the browser is trying to make one request (e.g. for domain3.html) on a new connection while it has an existing persistent connection already open. Having multiple host names pointing to the same server is not going to help; perhaps the browser does not realize that the two connections are to the same TCP server or that it could reuse the old connection.

A simple workaround would be to use the socketserver.ThreadingMixIn or ForkingMixIn class. Each TCP connection will then be handled in a background thread. The mixed-in TCPServer will not wait for the handler, and will accept concurrent connections.

If you want to avoid multiple threads, I think it is also possible to augment the server and handler classes to use “select” or similar so that the server will still handle each HTTP request one at a time, but can wait for requests on multiple TCP connections. But it requires subclassing and overriding some methods with custom code, and probably depends on deeper knowledge of how the classes work than is specified in the documentation.

For existing versions of Python, I don’t there is much that could be done other than documenting the shortcomings of how a persistent HTTP connection vs multiple connections is handled.
History
Date User Action Args
2017-10-01 00:06:32martin.pantersetrecipients: + martin.panter, ronaldoussoren, ned.deily, mattpr
2017-10-01 00:06:32martin.pantersetmessageid: <1506816392.73.0.213398074469.issue31639@psf.upfronthosting.co.za>
2017-10-01 00:06:32martin.panterlinkissue31639 messages
2017-10-01 00:06:29martin.pantercreate