From b9ab4ae1c29d72e6001e4692450b00fa90d2e3b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Me=C3=9Fmer?= Date: Sat, 15 Oct 2016 23:59:40 +0200 Subject: [PATCH] Add timeout parameter to subprocess.Popen.wait() (#607) Also define TimeoutExpired exception. --- stdlib/3/subprocess.pyi | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/stdlib/3/subprocess.pyi b/stdlib/3/subprocess.pyi index 8af789fb3..db359b1f1 100644 --- a/stdlib/3/subprocess.pyi +++ b/stdlib/3/subprocess.pyi @@ -12,12 +12,12 @@ if sys.version_info >= (3, 5): returncode = ... # type: int stdout = ... # type: Union[str, bytes] stderr = ... # type: Union[str, bytes] - def __init__(self, args: Union[List, str], - returncode: int, - stdout: Union[str, bytes], + def __init__(self, args: Union[List, str], + returncode: int, + stdout: Union[str, bytes], stderr: Union[str, bytes]) -> None: ... def check_returncode(self) -> None: ... - + # Nearly same args as Popen.__init__ except for timeout, input, and check def run(args: Union[str, Sequence[str]], timeout: float = ..., @@ -185,6 +185,7 @@ STDOUT = ... # type: Any if sys.version_info >= (3, 3): DEVNULL = ... # type: Any class SubprocessError(Exception): ... + class TimeoutExpired(SubprocessError): ... class CalledProcessError(Exception): @@ -226,7 +227,11 @@ class Popen: pass_fds: Any = ...) -> None: ... def poll(self) -> int: ... - def wait(self) -> int: ... + if sys.version_info >= (3, 3): + # 3.3 added timeout + def wait(self, timeout: float) -> int: ... + else: + def wait(self) ->int: ... # Return str/bytes if sys.version_info >= (3, 3): def communicate(self, input: Union[str, bytes] = ..., timeout: float = ...) -> Tuple[Any, Any]: ...