Fix up uses of Future as an argument in asyncio

Most functions which can take a Future can take Generators as well.
This commit is contained in:
David Fisher
2016-01-19 16:49:48 -08:00
parent 7c8797441b
commit 1a10134d54
2 changed files with 5 additions and 5 deletions

View File

@@ -1,4 +1,4 @@
from typing import Any, Awaitable, TypeVar, List, Callable, Tuple, Union, Dict
from typing import Any, Awaitable, TypeVar, List, Callable, Tuple, Union, Dict, Generator
from abc import ABCMeta, abstractmethod
from asyncio.futures import Future
@@ -34,7 +34,7 @@ class AbstractEventLoop(metaclass=ABCMeta):
@abstractmethod
def run_forever(self) -> None: ...
@abstractmethod
def run_until_complete(self, future: Union[Awaitable[_T], Future[_T]]) -> _T: ...
def run_until_complete(self, future: Union[Awaitable[_T], Future[_T], Generator[Any, Any, _T]]) -> _T: ...
@abstractmethod
def stop(self) -> None: ...
@abstractmethod

View File

@@ -1,4 +1,4 @@
from typing import Any, Iterable, TypeVar, Set, Dict, List, TextIO, Union, Tuple, Generic, Callable
from typing import Any, Iterable, TypeVar, Set, Dict, List, TextIO, Union, Tuple, Generic, Callable, Generator
from asyncio.events import AbstractEventLoop
from asyncio.futures import Future
# __all__ = ['iscoroutinefunction', 'iscoroutine',
@@ -18,7 +18,7 @@ def coroutine(f: _T) -> _T: ... # Here comes and go a function
def sleep(delay: float, result: _T = ..., loop: AbstractEventLoop = ...) -> Future[_T]: ...
def wait(fs: List[Task[_T]], *, loop: AbstractEventLoop = ...,
timeout: float = ..., return_when: str = ...) -> Future[Tuple[Set[Future[_T]], Set[Future[_T]]]]: ...
def wait_for(fut: Future[_T], timeout: float, *, loop: AbstractEventLoop = ...) -> Future[_T]: ...
def wait_for(fut: Union[Future[_T], Generator[Any, None, _T]], timeout: float, *, loop: AbstractEventLoop = ...) -> Future[_T]: ...
class Task(Future[_T], Generic[_T]):
@@ -28,7 +28,7 @@ class Task(Future[_T], Generic[_T]):
def current_task(cls, loop: AbstractEventLoop = ...) -> Task: ...
@classmethod
def all_tasks(cls, loop: AbstractEventLoop = ...) -> Set[Task]: ...
def __init__(self, coro: Future[_T], *, loop: AbstractEventLoop = ...) -> None: ...
def __init__(self, coro: Union[Future[_T], Generator[Any, None, _T]], *, loop: AbstractEventLoop = ...) -> None: ...
def __repr__(self) -> str: ...
def get_stack(self, *, limit: int = ...) -> List[Any]: ... # return List[stackframe]
def print_stack(self, *, limit: int = ..., file: TextIO = ...) -> None: ...