diff options
| author | Scott Gasch <[email protected]> | 2021-11-14 22:48:04 -0800 |
|---|---|---|
| committer | Scott Gasch <[email protected]> | 2021-11-14 22:48:04 -0800 |
| commit | 2c54bfde335f3631f045a871c540c9d63c5bb081 (patch) | |
| tree | 4a14470512c6a732e457f7c6f9540043d93b4296 /exec_utils.py | |
| parent | 8f7f3c61e14c903e0b9a151971940b945d306bfd (diff) | |
Tighten up the remote executor.
Diffstat (limited to 'exec_utils.py')
| -rw-r--r-- | exec_utils.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/exec_utils.py b/exec_utils.py index 7e9dae5..89cfbd7 100644 --- a/exec_utils.py +++ b/exec_utils.py @@ -1,11 +1,15 @@ #!/usr/bin/env python3 import atexit +import logging import shlex import subprocess from typing import List, Optional +logger = logging.getLogger(__file__) + + def cmd_with_timeout(command: str, timeout_seconds: Optional[float]) -> int: """ Run a command but do not let it run for more than timeout seconds. @@ -72,6 +76,7 @@ def cmd_in_background( stderr=subprocess.DEVNULL) else: subproc = subprocess.Popen(args, stdin=subprocess.DEVNULL) + def kill_subproc() -> None: try: if subproc.poll() is None: @@ -79,7 +84,7 @@ def cmd_in_background( subproc.terminate() subproc.wait(timeout=10.0) except BaseException as be: - log.error(be) + logger.exception(be) atexit.register(kill_subproc) return subproc |
