Skip to content

Commit 52a1c3d

Browse files
aarthy-dkclaude
andcommitted
fix(standalone): revert Windows signal forwarding to TerminateProcess
CTRL_BREAK_EVENT delivery is unreliable on Windows — the scheduler's threading.Event.wait doesn't wake on SIGBREAK from a different thread context, so the parent's children-watcher loop never empties and Ctrl+C hangs the whole tree. Reported by Chip; reproduced on the AWS WorkSpace. The orphan-postgres bug that motivated the CTRL_BREAK_EVENT switch is already addressed by the other half of fde7321 — children call ensure_standalone_setup() instead of get_server(), so they no longer register PIDs in pgserver's on-disk handle list. Force-killing them is safe; only the parent owns the pgserver handle and exits via the normal atexit path. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 82d4828 commit 52a1c3d

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

testgen/__main__.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,16 @@ def _install_shutdown_handler(handler) -> None:
146146

147147

148148
def _forward_signal_to_child(child: subprocess.Popen, signum: int) -> None:
149-
# POSIX: forward the signal verbatim. Windows: send CTRL_BREAK_EVENT so the
150-
# child's atexit hooks run (it deregisters from pgserver's PID list, lets
151-
# streamlit/uvicorn shut down their event loops, etc.). The child must have
152-
# been spawned with CREATE_NEW_PROCESS_GROUP — see _subprocess_spawn_kwargs.
149+
# POSIX: forward the signal verbatim. Windows: TerminateProcess — graceful
150+
# CTRL_BREAK_EVENT delivery is unreliable here because some children
151+
# (notably the scheduler thread blocked in threading.Event.wait, and
152+
# Streamlit/tornado) don't wake on SIGBREAK, leaving the parent's
153+
# children-watcher loop hung forever. Force-kill is safe: children no
154+
# longer call pgserver.get_server(), so there's no on-disk PID registry
155+
# state to clean up — only the parent owns the pgserver handle and
156+
# exits via the normal atexit path.
153157
if sys.platform == "win32":
154-
child.send_signal(signal.CTRL_BREAK_EVENT)
158+
child.terminate()
155159
else:
156160
child.send_signal(signum)
157161

0 commit comments

Comments
 (0)