From 09b9275ca28a8c67e7469980fe72d9bafedeb64c Mon Sep 17 00:00:00 2001 From: Nikhil Marathe Date: Wed, 1 Mar 2017 13:33:52 -0800 Subject: [PATCH] concurrent.futures: Add various Errors. Fix wait(). Introduces Error, CancelledError and TimeoutError, based on the backport. Also fixes the return type of wait to be Sets instead of Iterables. The function documentation promises Sets and the code uses Sets. https://github.com/agronholm/pythonfutures/blob/master/concurrent/futures/_base.py#L261 --- third_party/2/concurrent/futures/__init__.pyi | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/third_party/2/concurrent/futures/__init__.pyi b/third_party/2/concurrent/futures/__init__.pyi index 492ee1bfa906..5e5888876d70 100644 --- a/third_party/2/concurrent/futures/__init__.pyi +++ b/third_party/2/concurrent/futures/__init__.pyi @@ -1,7 +1,11 @@ -from typing import TypeVar, Generic, Any, Iterable, Iterator, Callable, Tuple, Union +from typing import TypeVar, Generic, Any, Iterable, Iterator, Callable, Optional, Set, Tuple, Union _T = TypeVar('_T') +class Error(Exception): ... +class CancelledError(Error): ... +class TimeoutError(Error): ... + class Future(Generic[_T]): def cancel(self) -> bool: ... def cancelled(self) -> bool: ... @@ -28,7 +32,7 @@ class ThreadPoolExecutor(Executor): class ProcessPoolExecutor(Executor): def __init__(self, max_workers: Union[int, None] = ...) -> None: ... -def wait(fs: Iterable[Future], timeout: float = ..., return_when: str = ...) -> Tuple[Iterable[Future], Iterable[Future]]: ... +def wait(fs: Iterable[Future], timeout: Optional[float] = ..., return_when: str = ...) -> Tuple[Set[Future], Set[Future]]: ... FIRST_COMPLETED = ... # type: str FIRST_EXCEPTION = ... # type: str