X-Git-Url: https://wannabe.guru.org/gitweb/?a=blobdiff_plain;f=exec_utils.py;h=282a325a461e289144b5a58b5a88ce4a90098c83;hb=e6f32fdd9b373dfcd100c7accb41f57d83c2f0a1;hp=016310793152ddeb8872f5ec279c26ae1994655e;hpb=36fea7f15ed17150691b5b3ead75450e575229ef;p=python_utils.git diff --git a/exec_utils.py b/exec_utils.py index 0163107..282a325 100644 --- a/exec_utils.py +++ b/exec_utils.py @@ -68,9 +68,7 @@ def cmd_with_timeout(command: str, timeout_seconds: Optional[float]) -> int: subprocess.TimeoutExpired: Command '['/bin/bash', '-c', '/bin/sleep 2']' timed out after 0.1 seconds """ - return subprocess.check_call( - ["/bin/bash", "-c", command], timeout=timeout_seconds - ) + return subprocess.check_call(["/bin/bash", "-c", command], timeout=timeout_seconds) def cmd(command: str, timeout_seconds: Optional[float] = None) -> str: @@ -120,9 +118,7 @@ def run_silently(command: str, timeout_seconds: Optional[float] = None) -> None: ) -def cmd_in_background( - command: str, *, silent: bool = False -) -> subprocess.Popen: +def cmd_in_background(command: str, *, silent: bool = False) -> subprocess.Popen: args = shlex.split(command) if silent: subproc = subprocess.Popen( @@ -137,9 +133,7 @@ def cmd_in_background( def kill_subproc() -> None: try: if subproc.poll() is None: - logger.info( - "At exit handler: killing {}: {}".format(subproc, command) - ) + logger.info("At exit handler: killing {}: {}".format(subproc, command)) subproc.terminate() subproc.wait(timeout=10.0) except BaseException as be: