Fix asyncio.wait for() and add exceptions (#676)

* asyncio.wait_for() should accept Awaitable[_T] same as asyncio.gather()

* {Cancelled,Timeout,InvalidState}Error types missing
This commit is contained in:
nobuggy
2016-11-10 20:00:43 +01:00
committed by Guido van Rossum
parent bf8b5ac5fd
commit 3f03849b70
3 changed files with 13 additions and 1 deletions

View File

@@ -37,6 +37,9 @@ from asyncio.transports import (
)
from asyncio.futures import (
Future as Future,
CancelledError as CancelledError,
TimeoutError as TimeoutError,
InvalidStateError as InvalidStateError,
)
from asyncio.tasks import (
FIRST_COMPLETED as FIRST_COMPLETED,

View File

@@ -5,6 +5,15 @@ __all__ = ... # type: str
_T = TypeVar('_T')
from concurrent.futures._base import (
Error as Error,
)
from concurrent.futures import (
CancelledError as CancelledError,
TimeoutError as TimeoutError,
)
class InvalidStateError(Error): ...
class _TracebackLogger:
__slots__ = ... # type: List[str]
exc = ... # type: BaseException

View File

@@ -30,7 +30,7 @@ def sleep(delay: float, result: _T = ..., loop: AbstractEventLoop = ...) -> Futu
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: Union[Future[_T], Generator[Any, None, _T]], timeout: Optional[float],
def wait_for(fut: Union[Future[_T], Generator[Any, None, _T], Awaitable[_T]], timeout: Optional[float],
*, loop: AbstractEventLoop = ...) -> Future[_T]: ...
class Task(Future[_T], Generic[_T]):