# Stubs for concurrent.futures._base (Python 3.5)
#
# NOTE: This dynamically typed stub was automatically generated by stubgen.

from typing import TypeVar, Generic, Any, Iterable, Iterator, Callable, Tuple
from collections import namedtuple

FIRST_COMPLETED = ... # type: Any
FIRST_EXCEPTION = ... # type: Any
ALL_COMPLETED = ... # type: Any
PENDING = ... # type: Any
RUNNING = ... # type: Any
CANCELLED = ... # type: Any
CANCELLED_AND_NOTIFIED = ... # type: Any
FINISHED = ... # type: Any
LOGGER = ... # type: Any

class Error(Exception): ...
class CancelledError(Error): ...
class TimeoutError(Error): ...

class _Waiter:
    event = ... # type: Any
    finished_futures = ... # type: Any
    def __init__(self): ...
    def add_result(self, future): ...
    def add_exception(self, future): ...
    def add_cancelled(self, future): ...

class _AsCompletedWaiter(_Waiter):
    lock = ... # type: Any
    def __init__(self): ...
    def add_result(self, future): ...
    def add_exception(self, future): ...
    def add_cancelled(self, future): ...

class _FirstCompletedWaiter(_Waiter):
    def add_result(self, future): ...
    def add_exception(self, future): ...
    def add_cancelled(self, future): ...

class _AllCompletedWaiter(_Waiter):
    num_pending_calls = ... # type: Any
    stop_on_exception = ... # type: Any
    lock = ... # type: Any
    def __init__(self, num_pending_calls, stop_on_exception): ...
    def add_result(self, future): ...
    def add_exception(self, future): ...
    def add_cancelled(self, future): ...

class _AcquireFutures:
    futures = ... # type: Any
    def __init__(self, futures): ...
    def __enter__(self): ...
    def __exit__(self, *args): ...

DoneAndNotDoneFutures = namedtuple('DoneAndNotDoneFutures', 'done not_done')

_T = TypeVar('_T')

class Future(Generic[_T]):
    def __init__(self) -> None: ...
    def cancel(self) -> bool: ...
    def cancelled(self) -> bool: ...
    def running(self) -> bool: ...
    def done(self) -> bool: ...
    def add_done_callback(self, fn: Callable[[Future], Any]) -> None: ...
    def result(self, timeout: float = ...) -> _T: ...
    def exception(self, timeout: float = ...) -> Exception: ...
    def set_running_or_notify_cancel(self) -> None: ...
    def set_result(self, result: _T) -> None: ...
    def set_exception(self, exception: Exception) -> None: ...

class Executor:
    def submit(self, fn: Callable[..., _T], *args: Any, **kwargs: Any) -> Future[_T]: ...
    def map(self, func: Callable[..., _T], *iterables: Any, timeout: float = ...) -> Iterable[_T]: ...
    def shutdown(self, wait: bool = ...) -> None: ...
    def __enter__(self) -> Executor: ...
    def __exit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> bool: ...

def as_completed(fs: Iterable[Future], timeout: float = ...) -> Iterator[Future]: ...

def wait(fs: Iterable[Future], timeout: float = ..., return_when: str = ...) -> Tuple[Iterable[Future], Iterable[Future]]: ...
