From 8e59579953a53924c2997bf014bf70229d06e9c9 Mon Sep 17 00:00:00 2001 From: Nikhil Marathe Date: Tue, 7 Mar 2017 16:39:25 -0800 Subject: [PATCH] concurrent.futures: Add various Errors. Fix wait(). (#964) 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 492ee1bfa..5e5888876 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