Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 33.9k
Open
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
The HTTPServer times out as expected before receiving the first request and after receiving the second request. However, HTTPServer doesn't timeout as expected between the first and second request, blocking until the second request is received by HTTPServer.
Your environment
- CPython versions tested on: 3.11.1
- Operating system and architecture: Windows 11 22H2 x64
Example code demonstrating the issue
fromhttp.serverimportBaseHTTPRequestHandler, HTTPServerclassHelloWorldHTTPRequestHandler(BaseHTTPRequestHandler): defdo_GET(self): self.send_response(200) self.send_header("Content-Type", "text/plain") self.end_headers() self.wfile.write("Hello World!".encode("utf8")) if__name__=="__main__": httpd=HTTPServer(("localhost", 65012), HelloWorldHTTPRequestHandler) httpd.timeout=1whileTrue: try: print("handle_request") httpd.handle_request() exceptKeyboardInterrupt: breakExample code output
handle_request handle_request handle_request handle_request 127.0.0.1 - - [22/Feb/2023 14:49:14] "GET / HTTP/1.1" 200 - handle_request 127.0.0.1 - - [22/Feb/2023 14:49:29] "GET / HTTP/1.1" 200 - handle_request handle_request handle_request handle_request handle_request handle_request handle_request handle_request handle_request KeyboardInterrupt Linked PRs
Metadata
Metadata
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error