mobly icon indicating copy to clipboard operation
mobly copied to clipboard

Refactor: Improve subprocess timeout handling

Open ko1in1u opened this issue 4 months ago • 0 comments

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.

ko1in1u avatar Aug 20 '25 21:08 ko1in1u