diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2017-11-13 00:00:30 +0100 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2017-11-13 00:00:30 +0100 |
commit | 40573cbe58407a3f8dfcb0c3b71237444b10fc0a (patch) | |
tree | 3ef2d6e9e50fdb89b475f83ae45ff690351a52f0 /psutil/_psposix.py | |
parent | 100391f880ef2a2c5b124bba4b0722623f3edb3e (diff) | |
download | psutil-40573cbe58407a3f8dfcb0c3b71237444b10fc0a.tar.gz |
#1174: use TimeoutExpired in wait_pid()
Diffstat (limited to 'psutil/_psposix.py')
-rw-r--r-- | psutil/_psposix.py | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/psutil/_psposix.py b/psutil/_psposix.py index 66d81a3d..6bb8444d 100644 --- a/psutil/_psposix.py +++ b/psutil/_psposix.py @@ -15,14 +15,10 @@ from ._common import sdiskusage from ._common import usage_percent from ._compat import PY3 from ._compat import unicode +from ._exceptions import TimeoutExpired -__all__ = ['TimeoutExpired', 'pid_exists', 'wait_pid', 'disk_usage', - 'get_terminal_map'] - - -class TimeoutExpired(Exception): - pass +__all__ = ['pid_exists', 'wait_pid', 'disk_usage', 'get_terminal_map'] def pid_exists(pid): @@ -53,7 +49,7 @@ def pid_exists(pid): return True -def wait_pid(pid, timeout=None): +def wait_pid(pid, timeout=None, proc_name=None): """Wait for process with pid 'pid' to terminate and return its exit status code as an integer. @@ -67,7 +63,7 @@ def wait_pid(pid, timeout=None): def check_timeout(delay): if timeout is not None: if timer() >= stop_at: - raise TimeoutExpired() + raise TimeoutExpired(timeout, pid=pid, name=proc_name) time.sleep(delay) return min(delay * 2, 0.04) |