Commit e4b79c9
committed
Fix Windows timeout mechanism in FallbackProcess.wait()
The FallbackProcess.wait() method was using to_thread.run_sync() with
subprocess.Popen.wait(), which is a blocking call that cannot be
interrupted by anyio's timeout mechanism. This caused the cleanup
sequence to wait indefinitely for processes to exit, ignoring the
2-second timeout.
The fix replaces the blocking wait with a polling approach that checks
process status every 0.1 seconds, allowing anyio.fail_after() to
properly interrupt the wait operation when the timeout expires.
This ensures the MCP spec-compliant shutdown sequence works correctly:
1. Close stdin and wait up to 2 seconds
2. If process doesn't exit, call terminate() and wait up to 2 seconds
3. If still running, force kill with taskkill
Reported-by: fweinberger1 parent a32ddda commit e4b79c9
File tree
3 files changed
+8
-94
lines changed- src/mcp/client/stdio
3 files changed
+8
-94
lines changedThis file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
185 | 185 | | |
186 | 186 | | |
187 | 187 | | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | 188 | | |
193 | 189 | | |
194 | | - | |
195 | 190 | | |
196 | | - | |
197 | | - | |
| 191 | + | |
198 | 192 | | |
199 | | - | |
200 | 193 | | |
201 | 194 | | |
202 | 195 | | |
203 | 196 | | |
204 | | - | |
205 | 197 | | |
206 | 198 | | |
207 | | - | |
208 | 199 | | |
209 | 200 | | |
210 | 201 | | |
211 | | - | |
212 | 202 | | |
213 | | - | |
214 | 203 | | |
215 | 204 | | |
216 | | - | |
217 | 205 | | |
218 | 206 | | |
219 | | - | |
220 | 207 | | |
221 | | - | |
222 | 208 | | |
223 | | - | |
224 | 209 | | |
225 | | - | |
226 | 210 | | |
227 | | - | |
228 | | - | |
229 | 211 | | |
230 | 212 | | |
231 | 213 | | |
| |||
283 | 265 | | |
284 | 266 | | |
285 | 267 | | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | 268 | | |
290 | 269 | | |
291 | 270 | | |
| |||
323 | 302 | | |
324 | 303 | | |
325 | 304 | | |
326 | | - | |
327 | 305 | | |
328 | | - | |
329 | 306 | | |
330 | 307 | | |
331 | | - | |
332 | 308 | | |
333 | 309 | | |
334 | | - | |
335 | | - | |
| 310 | + | |
336 | 311 | | |
337 | 312 | | |
338 | 313 | | |
339 | 314 | | |
340 | 315 | | |
341 | 316 | | |
342 | | - | |
343 | 317 | | |
344 | | - | |
345 | 318 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
92 | 93 | | |
93 | 94 | | |
94 | 95 | | |
95 | | - | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
96 | 101 | | |
97 | 102 | | |
98 | 103 | | |
| |||
0 commit comments