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
This commit is contained in:
Nikhil Marathe authored and Matthias Kramm committed 2017-03-07 16:39:25 -08:00
1 parent aa54fc1958
commit 8e59579953
1 file changed
+6 -2
+6 -2
View File
@@ -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