asyncio: various fixes (#3947)

* asyncio: remove BaseChildWatcher from top level

* asyncio.sleep: loop is keyword-only

* asyncio: remove Server from top level

* asyncio: add FastChildWatcher to top level

* asyncio.constants: fix version availability

* asyncio: fix arg name for _wakeup

* asyncio: fix arg name for wrap_future

* asyncio.streams: add Optional to various arguments

It might be possible to further improve some of these with overloads.

* stubtest: fix whitelist

Co-authored-by: hauntsaninja <>
This commit is contained in:
Shantanu
2020-04-30 17:04:36 -07:00
committed by GitHub
parent 630b50e458
commit fec46043ed
8 changed files with 18 additions and 37 deletions

View File

@@ -49,10 +49,7 @@ from asyncio.tasks import (
wait_for as wait_for,
Task as Task,
)
from asyncio.base_events import (
BaseEventLoop as BaseEventLoop,
Server as Server
)
from asyncio.base_events import BaseEventLoop as BaseEventLoop
from asyncio.events import (
AbstractEventLoopPolicy as AbstractEventLoopPolicy,
AbstractEventLoop as AbstractEventLoop,
@@ -112,7 +109,7 @@ if sys.version_info >= (3, 7):
if sys.platform != 'win32':
from .unix_events import (
AbstractChildWatcher as AbstractChildWatcher,
BaseChildWatcher as BaseChildWatcher,
FastChildWatcher as FastChildWatcher,
SafeChildWatcher as SafeChildWatcher,
SelectorEventLoop as SelectorEventLoop,
)

View File

@@ -1,11 +1,14 @@
import enum
import sys
LOG_THRESHOLD_FOR_CONNLOST_WRITES: int
ACCEPT_RETRY_DELAY: int
DEBUG_STACK_DEPTH: int
SSL_HANDSHAKE_TIMEOUT: float
SENDFILE_FALLBACK_READBUFFER_SIZE: int
if sys.version_info >= (3, 6):
DEBUG_STACK_DEPTH: int
if sys.version_info >= (3, 7):
SSL_HANDSHAKE_TIMEOUT: float
SENDFILE_FALLBACK_READBUFFER_SIZE: int
class _SendfileMode(enum.Enum):
UNSUPPORTED: int = ...

View File

@@ -59,4 +59,4 @@ class Future(Awaitable[_T], Iterable[_T]):
@property
def _loop(self) -> AbstractEventLoop: ...
def wrap_future(f: Union[_ConcurrentFuture[_T], Future[_T]], *, loop: Optional[AbstractEventLoop] = ...) -> Future[_T]: ...
def wrap_future(future: Union[_ConcurrentFuture[_T], Future[_T]], *, loop: Optional[AbstractEventLoop] = ...) -> Future[_T]: ...

View File

@@ -18,8 +18,8 @@ if sys.version_info < (3, 8):
def __init__(self, message: str, consumed: int) -> None: ...
async def open_connection(
host: str = ...,
port: Union[int, str] = ...,
host: Optional[str] = ...,
port: Optional[Union[int, str]] = ...,
*,
loop: Optional[events.AbstractEventLoop] = ...,
limit: int = ...,
@@ -46,7 +46,7 @@ if sys.platform != 'win32':
_PathType = str
async def open_unix_connection(
path: _PathType = ...,
path: Optional[_PathType] = ...,
*,
loop: Optional[events.AbstractEventLoop] = ...,
limit: int = ...,
@@ -55,7 +55,7 @@ if sys.platform != 'win32':
async def start_unix_server(
client_connected_cb: _ClientConnectedCallback,
path: _PathType = ...,
path: Optional[_PathType] = ...,
*,
loop: Optional[events.AbstractEventLoop] = ...,
limit: int = ...,
@@ -66,7 +66,7 @@ class FlowControlMixin(protocols.Protocol): ...
class StreamReaderProtocol(FlowControlMixin, protocols.Protocol):
def __init__(self,
stream_reader: StreamReader,
client_connected_cb: _ClientConnectedCallback = ...,
client_connected_cb: Optional[_ClientConnectedCallback] = ...,
loop: Optional[events.AbstractEventLoop] = ...) -> None: ...
def connection_made(self, transport: transports.BaseTransport) -> None: ...
def connection_lost(self, exc: Optional[Exception]) -> None: ...

View File

@@ -85,7 +85,7 @@ def gather(coro_or_future1: _FutureT[_T1], coro_or_future2: _FutureT[_T2], coro_
def run_coroutine_threadsafe(coro: _FutureT[_T],
loop: AbstractEventLoop) -> concurrent.futures.Future[_T]: ...
def shield(arg: _FutureT[_T], *, loop: Optional[AbstractEventLoop] = ...) -> Future[_T]: ...
def sleep(delay: float, result: _T = ..., loop: Optional[AbstractEventLoop] = ...) -> Future[_T]: ...
def sleep(delay: float, result: _T = ..., *, loop: Optional[AbstractEventLoop] = ...) -> Future[_T]: ...
def wait(fs: Iterable[_FutureT[_T]], *, loop: Optional[AbstractEventLoop] = ..., timeout: Optional[float] = ...,
return_when: str = ...) -> Future[Tuple[Set[Future[_T]], Set[Future[_T]]]]: ...
def wait_for(fut: _FutureT[_T], timeout: Optional[float],
@@ -115,7 +115,7 @@ class Task(Future[_T], Generic[_T]):
def print_stack(self, *, limit: int = ..., file: TextIO = ...) -> None: ...
def cancel(self) -> bool: ...
if sys.version_info < (3, 7):
def _wakeup(self, future: Future[Any]) -> None: ...
def _wakeup(self, fut: Future[Any]) -> None: ...
if sys.version_info >= (3, 7):
def all_tasks(loop: Optional[AbstractEventLoop] = ...) -> Set[Task[Any]]: ...