Commit 0b882fb
fix(testgen): kill the whole subprocess tree on tg start/install shutdown
`proc.terminate()` on Windows calls `TerminateProcess` and only kills the
parent — pixeltable-pgserver's `postgres.exe` children get orphaned. The
symptom: `tg delete` fails with "Could not remove TestGen data directory"
because postgres holds the data files open.
New `stop_app_tree(proc, timeout=...)` walks the descendant tree:
- Windows: shells out to `taskkill /F /T /PID` to walk the WMI process tree.
- POSIX: sends SIGTERM to the process group (parent is now spawned with
`start_new_session=True`), escalating to SIGKILL on timeout.
Routed all three termination sites in `start_testgen_app` through the
helper (port-readiness timeout, KeyboardInterrupt handler, finally
cleanup). Added unit tests covering the platform branching and the
SIGKILL escalation path.
Note: this is a force-kill safety net for uncatchable termination paths
(installer crash, terminal X-button close, hang). Graceful shutdown on
Ctrl+C is a separate fix in pixeltable-pgserver / testgen's signal
handling — see the issue we drafted for the testgen team.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent e8aec12 commit 0b882fb
2 files changed
Lines changed: 126 additions & 23 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
2464 | 2465 | | |
2465 | 2466 | | |
2466 | 2467 | | |
| 2468 | + | |
| 2469 | + | |
| 2470 | + | |
| 2471 | + | |
| 2472 | + | |
| 2473 | + | |
| 2474 | + | |
| 2475 | + | |
| 2476 | + | |
| 2477 | + | |
| 2478 | + | |
| 2479 | + | |
| 2480 | + | |
| 2481 | + | |
| 2482 | + | |
| 2483 | + | |
| 2484 | + | |
| 2485 | + | |
| 2486 | + | |
| 2487 | + | |
| 2488 | + | |
| 2489 | + | |
| 2490 | + | |
| 2491 | + | |
| 2492 | + | |
| 2493 | + | |
| 2494 | + | |
| 2495 | + | |
| 2496 | + | |
| 2497 | + | |
| 2498 | + | |
| 2499 | + | |
| 2500 | + | |
| 2501 | + | |
2467 | 2502 | | |
2468 | 2503 | | |
2469 | 2504 | | |
| |||
2496 | 2531 | | |
2497 | 2532 | | |
2498 | 2533 | | |
| 2534 | + | |
| 2535 | + | |
| 2536 | + | |
| 2537 | + | |
2499 | 2538 | | |
2500 | 2539 | | |
2501 | 2540 | | |
2502 | 2541 | | |
2503 | 2542 | | |
2504 | 2543 | | |
2505 | | - | |
2506 | | - | |
2507 | | - | |
| 2544 | + | |
2508 | 2545 | | |
2509 | 2546 | | |
2510 | 2547 | | |
| |||
2526 | 2563 | | |
2527 | 2564 | | |
2528 | 2565 | | |
2529 | | - | |
2530 | | - | |
2531 | | - | |
2532 | | - | |
2533 | | - | |
2534 | | - | |
| 2566 | + | |
2535 | 2567 | | |
2536 | 2568 | | |
2537 | 2569 | | |
2538 | | - | |
2539 | | - | |
2540 | | - | |
2541 | | - | |
| 2570 | + | |
2542 | 2571 | | |
2543 | 2572 | | |
2544 | 2573 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
93 | 94 | | |
94 | 95 | | |
95 | 96 | | |
| 97 | + | |
96 | 98 | | |
97 | 99 | | |
98 | 100 | | |
99 | 101 | | |
100 | | - | |
| 102 | + | |
101 | 103 | | |
102 | 104 | | |
103 | 105 | | |
104 | 106 | | |
105 | | - | |
106 | | - | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
107 | 110 | | |
108 | 111 | | |
109 | 112 | | |
110 | | - | |
111 | 113 | | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | 114 | | |
118 | 115 | | |
119 | 116 | | |
120 | 117 | | |
121 | 118 | | |
122 | 119 | | |
| 120 | + | |
123 | 121 | | |
124 | 122 | | |
125 | 123 | | |
126 | | - | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
127 | 128 | | |
128 | 129 | | |
129 | 130 | | |
130 | 131 | | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
131 | 205 | | |
132 | 206 | | |
133 | 207 | | |
| |||
0 commit comments