Skip to content

Conversation

@ko1in1u
Copy link
Collaborator

@ko1in1u ko1in1u commented Aug 20, 2025

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 ko1in1u added this to the Mobly Release 1.13.1 milestone Aug 20, 2025
@ko1in1u ko1in1u requested review from mhaoli and xianyuanjia August 20, 2025 21:24
@ko1in1u ko1in1u self-assigned this Aug 20, 2025
@ko1in1u ko1in1u added the bug label Aug 20, 2025
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`.
cwd=cwd,
env=env,
universal_newlines=universal_newlines,
text=universal_newlines, # "text" is introdcued in Python 3.7.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is text functionally identical to universal_newline?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, text is the modern and preferred keyword for handling text mode. universal_newlines is the older and deprecated equivalent.

@ko1in1u ko1in1u requested a review from xpconanfan September 4, 2025 19:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants