Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 51 additions & 7 deletions stdlib/3/concurrent/futures/_base.pyi
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
from typing import TypeVar, Generic, Any, Iterable, Iterator, Callable, Tuple, Optional, Set
import threading
from logging import Logger
from typing import TypeVar, Generic, Any, Iterable, Iterator, Callable, Tuple, Optional, Set, List
from types import TracebackType
import sys

FIRST_COMPLETED: str
FIRST_EXCEPTION: str
ALL_COMPLETED: str
PENDING: Any
RUNNING: Any
CANCELLED: Any
CANCELLED_AND_NOTIFIED: Any
FINISHED: Any
LOGGER: Any
PENDING: str
RUNNING: str
CANCELLED: str
CANCELLED_AND_NOTIFIED: str
FINISHED: str
LOGGER: Logger

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

if sys.version_info >= (3, 7):
class BrokenExecutor(RuntimeError): ...

_T = TypeVar('_T')

class Future(Generic[_T]):
Expand Down Expand Up @@ -54,3 +59,42 @@ def as_completed(fs: Iterable[Future[_T]], timeout: Optional[float] = ...) -> It

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

class _Waiter:
event: threading.Event
finished_futures: List[Future]
def __init__(self) -> None: ...
def add_result(self, future: Future) -> None: ...
def add_exception(self, future: Future) -> None: ...
def add_cancelled(self, future: Future) -> None: ...


class _AsCompletedWaiter(_Waiter):
lock: threading.Lock
def __init__(self) -> None: ...
def add_result(self, future: Future) -> None: ...
def add_exception(self, future: Future) -> None: ...
def add_cancelled(self, future: Future) -> None: ...


class _FirstCompletedWaiter(_Waiter):
def add_result(self, future: Future) -> None: ...
def add_exception(self, future: Future) -> None: ...
def add_cancelled(self, future: Future) -> None: ...


class _AllCompletedWaiter(_Waiter):
num_pending_calls: int
stop_on_exception: bool
lock: threading.Lock
def __init__(self, num_pending_calls: int, stop_on_exception: bool) -> None: ...
def add_result(self, future: Future) -> None: ...
def add_exception(self, future: Future) -> None: ...
def add_cancelled(self, future: Future) -> None: ...


class _AcquireFutures:
futures: Iterable[Future]
def __init__(self, futures: Iterable[Future]) -> None: ...
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This Iterable is fine on the other hand.

def __enter__(self) -> None: ...
def __exit__(self, *args: Any) -> None: ...
20 changes: 18 additions & 2 deletions stdlib/3/concurrent/futures/thread.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
from typing import Any, Callable, Optional, Tuple
from ._base import Executor
from typing import Any, Callable, Optional, Tuple, TypeVar, Generic
from ._base import Executor, Future
import sys

if sys.version_info >= (3, 7):
from ._base import BrokenExecutor
class BrokenThreadPool(BrokenExecutor): ...

_S = TypeVar('_S')

class ThreadPoolExecutor(Executor):
if sys.version_info >= (3, 7):
def __init__(self, max_workers: Optional[int] = ...,
Expand All @@ -13,3 +19,13 @@ class ThreadPoolExecutor(Executor):
thread_name_prefix: str = ...) -> None: ...
else:
def __init__(self, max_workers: Optional[int] = ...) -> None: ...


class _WorkItem(Generic[_S]):
future: Future
fn: Callable[[Future[_S]], Any]
args: Any
kwargs: Any
def __init__(self, future: Future, fn: Callable[[Future[_S]], Any], args: Any,
kwargs: Any) -> None: ...
def run(self) -> None: ...
58 changes: 51 additions & 7 deletions third_party/2/concurrent/futures/_base.pyi
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
from typing import TypeVar, Generic, Any, Iterable, Iterator, Callable, Tuple, Optional, Set
import threading
from logging import Logger
from typing import TypeVar, Generic, Any, Iterable, Iterator, Callable, Tuple, Optional, Set, List
from types import TracebackType
import sys

FIRST_COMPLETED: str
FIRST_EXCEPTION: str
ALL_COMPLETED: str
PENDING: Any
RUNNING: Any
CANCELLED: Any
CANCELLED_AND_NOTIFIED: Any
FINISHED: Any
LOGGER: Any
PENDING: str
RUNNING: str
CANCELLED: str
CANCELLED_AND_NOTIFIED: str
FINISHED: str
LOGGER: Logger

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

if sys.version_info >= (3, 7):
class BrokenExecutor(RuntimeError): ...

_T = TypeVar('_T')

class Future(Generic[_T]):
Expand Down Expand Up @@ -54,3 +59,42 @@ def as_completed(fs: Iterable[Future[_T]], timeout: Optional[float] = ...) -> It

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

class _Waiter:
event: threading.Event
finished_futures: List[Future]
def __init__(self) -> None: ...
def add_result(self, future: Future) -> None: ...
def add_exception(self, future: Future) -> None: ...
def add_cancelled(self, future: Future) -> None: ...


class _AsCompletedWaiter(_Waiter):
lock: threading.Lock
def __init__(self) -> None: ...
def add_result(self, future: Future) -> None: ...
def add_exception(self, future: Future) -> None: ...
def add_cancelled(self, future: Future) -> None: ...


class _FirstCompletedWaiter(_Waiter):
def add_result(self, future: Future) -> None: ...
def add_exception(self, future: Future) -> None: ...
def add_cancelled(self, future: Future) -> None: ...


class _AllCompletedWaiter(_Waiter):
num_pending_calls: int
stop_on_exception: bool
lock: threading.Lock
def __init__(self, num_pending_calls: int, stop_on_exception: bool) -> None: ...
def add_result(self, future: Future) -> None: ...
def add_exception(self, future: Future) -> None: ...
def add_cancelled(self, future: Future) -> None: ...


class _AcquireFutures:
futures: Iterable[Future]
def __init__(self, futures: Iterable[Future]) -> None: ...
def __enter__(self) -> None: ...
def __exit__(self, *args: Any) -> None: ...
20 changes: 18 additions & 2 deletions third_party/2/concurrent/futures/thread.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
from typing import Any, Callable, Optional, Tuple
from ._base import Executor
from typing import Any, Callable, Optional, Tuple, TypeVar, Generic
from ._base import Executor, Future
import sys

if sys.version_info >= (3, 7):
from ._base import BrokenExecutor
class BrokenThreadPool(BrokenExecutor): ...

_S = TypeVar('_S')

class ThreadPoolExecutor(Executor):
if sys.version_info >= (3, 7):
def __init__(self, max_workers: Optional[int] = ...,
Expand All @@ -13,3 +19,13 @@ class ThreadPoolExecutor(Executor):
thread_name_prefix: str = ...) -> None: ...
else:
def __init__(self, max_workers: Optional[int] = ...) -> None: ...


class _WorkItem(Generic[_S]):
future: Future
fn: Callable[[Future[_S]], Any]
args: Any
kwargs: Any
def __init__(self, future: Future, fn: Callable[[Future[_S]], Any], args: Any,
kwargs: Any) -> None: ...
def run(self) -> None: ...