AbstractEventLoop missing methods from 3.4.2 and up. (#798)

* Update asyncio/events.pyi for python 3.5.2
create_future, create_task, set_task_factory, get_task_factory
* Gate create_future to >= (3, 5)
This commit is contained in:
Jason Fried
2017-01-03 11:05:04 -08:00
committed by Łukasz Langa
parent 844b32cc64
commit 61cdd4b7ae

View File

@@ -1,7 +1,9 @@
from typing import Any, Awaitable, TypeVar, List, Callable, Tuple, Union, Dict, Generator, overload
import sys
from typing import Any, Awaitable, TypeVar, List, Callable, Tuple, Union, Dict, Generator, overload, Optional
from abc import ABCMeta, abstractmethod
from asyncio.futures import Future
from asyncio.coroutines import coroutine
from asyncio.tasks import Task
__all__ = ... # type: str
@@ -53,6 +55,17 @@ class AbstractEventLoop(metaclass=ABCMeta):
def call_at(self, when: float, callback: Callable[..., Any], *args: Any) -> Handle: ...
@abstractmethod
def time(self) -> float: ...
# Future methods
if sys.version_info >= (3, 5):
@abstractmethod
def create_future(self) -> Future[Any]: ...
# Tasks methods
@abstractmethod
def create_task(self, coro: Union[Future[_T], Generator[Any, None, _T]]) -> Task[_T]: ...
@abstractmethod
def set_task_factory(self, factory: Optional[Callable[[AbstractEventLoop, Generator[Any, None, _T]], Future[_T]]]) -> None: ...
@abstractmethod
def get_task_factory(self) -> Optional[Callable[[AbstractEventLoop, Generator[Any, None, _T]], Future[_T]]]: ...
# Methods for interacting with threads
@abstractmethod
def call_soon_threadsafe(self, callback: Callable[..., Any], *args: Any) -> Handle: ...