Commit b257cc1
committed
Refactor: Improve subprocess timeout handling
This refactors `run_command` to use `subprocess.Popen.communicate(timeout=...)` for a more robust timeout mechanism.
The old method, relying on a custom `threading.Timer`, could fail to terminate stubborn processes like `fastboot oem dmesg` which ignore `SIGTERM`. The new approach uses `communicate()`, which sends a forceful `SIGKILL` on timeout, guaranteeing the process is terminated.
This change also updates the code to use the modern `text` argument introduced in Python 3.7 to replace `universal_newlines`.1 parent c6692ad commit b257cc1
2 files changed
+19
-36
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
474 | 474 | | |
475 | 475 | | |
476 | 476 | | |
477 | | - | |
| 477 | + | |
478 | 478 | | |
479 | | - | |
480 | | - | |
481 | | - | |
482 | | - | |
483 | | - | |
484 | | - | |
485 | | - | |
486 | | - | |
487 | | - | |
488 | | - | |
489 | | - | |
490 | | - | |
491 | | - | |
492 | | - | |
493 | | - | |
494 | | - | |
495 | | - | |
496 | | - | |
497 | | - | |
498 | | - | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
499 | 493 | | |
500 | | - | |
501 | | - | |
502 | | - | |
503 | | - | |
504 | | - | |
505 | | - | |
506 | | - | |
507 | 494 | | |
508 | 495 | | |
509 | 496 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
298 | 298 | | |
299 | 299 | | |
300 | 300 | | |
301 | | - | |
302 | 301 | | |
303 | | - | |
| 302 | + | |
304 | 303 | | |
305 | 304 | | |
306 | 305 | | |
| |||
316 | 315 | | |
317 | 316 | | |
318 | 317 | | |
319 | | - | |
| 318 | + | |
320 | 319 | | |
321 | | - | |
322 | 320 | | |
323 | | - | |
324 | 321 | | |
325 | | - | |
| 322 | + | |
326 | 323 | | |
327 | 324 | | |
328 | 325 | | |
| |||
352 | 349 | | |
353 | 350 | | |
354 | 351 | | |
355 | | - | |
| 352 | + | |
356 | 353 | | |
357 | | - | |
358 | 354 | | |
359 | 355 | | |
360 | 356 | | |
| |||
0 commit comments