Fix python_server.py infinite loop on EOF (fixes #25620) by anthonykim1 · Pull Request #25746 · microsoft/vscode-python
When VS Code closes, the STDIN stream closes and readline() returns empty bytes (b''). Previously this was incorrectly treated as an empty line separator, causing an infinite loop with 100% CPU usage. This fix: - Detects EOF in get_headers() by checking for b'' and raising EOFError - Handles EOFError in all three places that call get_headers(): - The main loop - handle_response() - custom_input() - Exits gracefully with sys.exit(0) when EOF is detected The key insight is distinguishing between: - EOF: readline() returns b'' (empty bytes) - Empty line: readline() returns b'\r\n' or b'\n' (newline bytes) Also added comprehensive unit tests to verify the fix.
anthonykim1
added
the
bug
label
Jan 22, 2026This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters