diff options
author | Guillermo <guille@users.noreply.github.com> | 2021-02-18 13:18:22 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-18 13:18:22 +0100 |
commit | dd237b19a4ca286ed7ce9f89b213b2848c9078cf (patch) | |
tree | 0b285e7197785d554735cc3715196ab1defcbe0a | |
parent | e80cabe5206fd7ef14fd6a47e2571f660f95babf (diff) | |
download | psutil-dd237b19a4ca286ed7ce9f89b213b2848c9078cf.tar.gz |
Linux: wait_procs ignoring timeout (#1913) (#1917)
The function was exiting after one second due to a subprocess.TimeoutException
Fixes #1913
Signed-off-by: guille <guille@users.noreply.github.com>
-rw-r--r-- | CREDITS | 4 | ||||
-rw-r--r-- | HISTORY.rst | 1 | ||||
-rw-r--r-- | psutil/__init__.py | 3 | ||||
-rw-r--r-- | psutil/_compat.py | 8 |
4 files changed, 16 insertions, 0 deletions
@@ -736,3 +736,7 @@ I: 1822 N: marxin W: https://github.com/marxin I: 1851 + +N: guille +W: https://github.com/guille +I: 1913 diff --git a/HISTORY.rst b/HISTORY.rst index dc4afbff..0998908a 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -20,6 +20,7 @@ XXXX-XX-XX - 1892_: [macOS] psutil.cpu_freq() broken on Apple M1. - 1904_: [Windows] OpenProcess fails with ERROR_SUCCESS due to GetLastError() called after sprintf(). (patch by alxchk) +- 1913_: [Linux] wait_procs seemingly ignoring timeout, TimeoutExpired thrown 5.8.0 ===== diff --git a/psutil/__init__.py b/psutil/__init__.py index 44efb7ff..7dac47d5 100644 --- a/psutil/__init__.py +++ b/psutil/__init__.py @@ -47,6 +47,7 @@ from ._common import ZombieProcess from ._compat import long from ._compat import PermissionError from ._compat import ProcessLookupError +from ._compat import SubprocessTimeoutExpired as _SubprocessTimeoutExpired from ._compat import PY3 as _PY3 from ._common import CONN_CLOSE @@ -1505,6 +1506,8 @@ def wait_procs(procs, timeout=None, callback=None): returncode = proc.wait(timeout=timeout) except TimeoutExpired: pass + except _SubprocessTimeoutExpired: + pass else: if returncode is not None or not proc.is_running(): # Set new Process instance attribute. diff --git a/psutil/_compat.py b/psutil/_compat.py index 17f38485..90938687 100644 --- a/psutil/_compat.py +++ b/psutil/_compat.py @@ -422,3 +422,11 @@ except ImportError: return (res[1], res[0]) except Exception: return fallback + + +# python 3.3 +try: + from subprocess import TimeoutExpired as SubprocessTimeoutExpired +except ImportError: + class SubprocessTimeoutExpired: + pass |