Use async syntax instead of @coroutine (#3441)

This commit is contained in:
Sebastian Rittau
2019-11-06 16:39:09 +01:00
committed by Jelle Zijlstra
parent add0b5e930
commit e4677d9ed4
8 changed files with 127 additions and 193 deletions

View File

@@ -5,7 +5,6 @@ import sys
from typing import Any, Awaitable, Callable, Dict, Generator, IO, List, Optional, Sequence, Tuple, TypeVar, Union, overload
from abc import ABCMeta
from asyncio.futures import Future
from asyncio.coroutines import coroutine
from asyncio.events import AbstractEventLoop, AbstractServer, Handle, TimerHandle
from asyncio.protocols import BaseProtocol
from asyncio.tasks import Task
@@ -37,8 +36,7 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta):
def is_closed(self) -> bool: ...
def close(self) -> None: ...
if sys.version_info >= (3, 6):
@coroutine
def shutdown_asyncgens(self) -> Generator[Any, None, None]: ...
async def shutdown_asyncgens(self) -> None: ...
# Methods scheduling callbacks. All these return Handles.
if sys.version_info >= (3, 7):
def call_soon(self, callback: Callable[..., Any], *args: Any, context: Optional[Context] = ...) -> Handle: ...
@@ -69,19 +67,16 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta):
def call_soon_threadsafe(self, callback: Callable[..., Any], *args: Any, context: Optional[Context] = ...) -> Handle: ...
else:
def call_soon_threadsafe(self, callback: Callable[..., Any], *args: Any) -> Handle: ...
@coroutine
def run_in_executor(self, executor: Any,
func: Callable[..., _T], *args: Any) -> Generator[Any, None, _T]: ...
async def run_in_executor(self, executor: Any,
func: Callable[..., _T], *args: Any) -> _T: ...
def set_default_executor(self, executor: Any) -> None: ...
# Network I/O methods returning Futures.
@coroutine
# TODO the "Tuple[Any, ...]" should be "Union[Tuple[str, int], Tuple[str, int, int, int]]" but that triggers
# https://github.com/python/mypy/issues/2509
def getaddrinfo(self, host: Optional[str], port: Union[str, int, None], *,
family: int = ..., type: int = ..., proto: int = ...,
flags: int = ...) -> Generator[Any, None, List[Tuple[int, int, int, str, Tuple[Any, ...]]]]: ...
@coroutine
def getnameinfo(self, sockaddr: Tuple[Any, ...], flags: int = ...) -> Generator[Any, None, Tuple[str, int]]: ...
async def getaddrinfo(self, host: Optional[str], port: Union[str, int, None], *,
family: int = ..., type: int = ..., proto: int = ...,
flags: int = ...) -> List[Tuple[int, int, int, str, Tuple[Any, ...]]]: ...
async def getnameinfo(self, sockaddr: Tuple[Any, ...], flags: int = ...) -> Tuple[str, int]: ...
if sys.version_info >= (3, 8):
@overload
async def create_connection(
@@ -132,15 +127,13 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta):
ssl_handshake_timeout: Optional[float] = ...) -> _TransProtPair: ...
else:
@overload
@coroutine
def create_connection(self, protocol_factory: _ProtocolFactory, host: str = ..., port: int = ..., *,
ssl: _SSLContext = ..., family: int = ..., proto: int = ..., flags: int = ..., sock: None = ...,
local_addr: Optional[str] = ..., server_hostname: Optional[str] = ...) -> Generator[Any, None, _TransProtPair]: ...
async def create_connection(self, protocol_factory: _ProtocolFactory, host: str = ..., port: int = ..., *,
ssl: _SSLContext = ..., family: int = ..., proto: int = ..., flags: int = ..., sock: None = ...,
local_addr: Optional[str] = ..., server_hostname: Optional[str] = ...) -> _TransProtPair: ...
@overload
@coroutine
def create_connection(self, protocol_factory: _ProtocolFactory, host: None = ..., port: None = ..., *,
ssl: _SSLContext = ..., family: int = ..., proto: int = ..., flags: int = ..., sock: socket,
local_addr: None = ..., server_hostname: Optional[str] = ...) -> Generator[Any, None, _TransProtPair]: ...
async def create_connection(self, protocol_factory: _ProtocolFactory, host: None = ..., port: None = ..., *,
ssl: _SSLContext = ..., family: int = ..., proto: int = ..., flags: int = ..., sock: socket,
local_addr: None = ..., server_hostname: Optional[str] = ...) -> _TransProtPair: ...
if sys.version_info >= (3, 7):
async def sock_sendfile(self, sock: socket, file: IO[bytes], offset: int = ..., count: Optional[int] = ..., *,
fallback: bool = ...) -> int: ...
@@ -163,41 +156,33 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta):
ssl_handshake_timeout: Optional[float] = ...) -> BaseTransport: ...
else:
@overload
@coroutine
def create_server(self, protocol_factory: _ProtocolFactory, host: Optional[Union[str, Sequence[str]]] = ..., port: int = ..., *,
family: int = ..., flags: int = ...,
sock: None = ..., backlog: int = ..., ssl: _SSLContext = ...,
reuse_address: Optional[bool] = ...,
reuse_port: Optional[bool] = ...) -> Generator[Any, None, Server]: ...
async def create_server(self, protocol_factory: _ProtocolFactory, host: Optional[Union[str, Sequence[str]]] = ..., port: int = ..., *,
family: int = ..., flags: int = ...,
sock: None = ..., backlog: int = ..., ssl: _SSLContext = ...,
reuse_address: Optional[bool] = ...,
reuse_port: Optional[bool] = ...) -> Server: ...
@overload
@coroutine
def create_server(self, protocol_factory: _ProtocolFactory, host: None = ..., port: None = ..., *,
family: int = ..., flags: int = ...,
sock: socket, backlog: int = ..., ssl: _SSLContext = ...,
reuse_address: Optional[bool] = ...,
reuse_port: Optional[bool] = ...) -> Generator[Any, None, Server]: ...
@coroutine
def connect_accepted_socket(self, protocol_factory: _ProtocolFactory, sock: socket, *, ssl: _SSLContext = ...) -> Generator[Any, None, _TransProtPair]: ...
@coroutine
def create_datagram_endpoint(self, protocol_factory: _ProtocolFactory,
local_addr: Optional[Tuple[str, int]] = ..., remote_addr: Optional[Tuple[str, int]] = ..., *,
family: int = ..., proto: int = ..., flags: int = ...,
reuse_address: Optional[bool] = ..., reuse_port: Optional[bool] = ...,
allow_broadcast: Optional[bool] = ...,
sock: Optional[socket] = ...) -> Generator[Any, None, _TransProtPair]: ...
async def create_server(self, protocol_factory: _ProtocolFactory, host: None = ..., port: None = ..., *,
family: int = ..., flags: int = ...,
sock: socket, backlog: int = ..., ssl: _SSLContext = ...,
reuse_address: Optional[bool] = ...,
reuse_port: Optional[bool] = ...) -> Server: ...
async def connect_accepted_socket(self, protocol_factory: _ProtocolFactory, sock: socket, *, ssl: _SSLContext = ...) -> _TransProtPair: ...
async def create_datagram_endpoint(self, protocol_factory: _ProtocolFactory,
local_addr: Optional[Tuple[str, int]] = ..., remote_addr: Optional[Tuple[str, int]] = ..., *,
family: int = ..., proto: int = ..., flags: int = ...,
reuse_address: Optional[bool] = ..., reuse_port: Optional[bool] = ...,
allow_broadcast: Optional[bool] = ...,
sock: Optional[socket] = ...) -> _TransProtPair: ...
# Pipes and subprocesses.
@coroutine
def connect_read_pipe(self, protocol_factory: _ProtocolFactory, pipe: Any) -> Generator[Any, None, _TransProtPair]: ...
@coroutine
def connect_write_pipe(self, protocol_factory: _ProtocolFactory, pipe: Any) -> Generator[Any, None, _TransProtPair]: ...
@coroutine
def subprocess_shell(self, protocol_factory: _ProtocolFactory, cmd: Union[bytes, str], *, stdin: Any = ...,
stdout: Any = ..., stderr: Any = ...,
**kwargs: Any) -> Generator[Any, None, _TransProtPair]: ...
@coroutine
def subprocess_exec(self, protocol_factory: _ProtocolFactory, *args: Any, stdin: Any = ...,
stdout: Any = ..., stderr: Any = ...,
**kwargs: Any) -> Generator[Any, None, _TransProtPair]: ...
async def connect_read_pipe(self, protocol_factory: _ProtocolFactory, pipe: Any) -> _TransProtPair: ...
async def connect_write_pipe(self, protocol_factory: _ProtocolFactory, pipe: Any) -> _TransProtPair: ...
async def subprocess_shell(self, protocol_factory: _ProtocolFactory, cmd: Union[bytes, str], *, stdin: Any = ...,
stdout: Any = ..., stderr: Any = ...,
**kwargs: Any) -> _TransProtPair: ...
async def subprocess_exec(self, protocol_factory: _ProtocolFactory, *args: Any, stdin: Any = ...,
stdout: Any = ..., stderr: Any = ...,
**kwargs: Any) -> _TransProtPair: ...
def add_reader(self, fd: selectors._FileObject, callback: Callable[..., Any], *args: Any) -> None: ...
def remove_reader(self, fd: selectors._FileObject) -> None: ...
def add_writer(self, fd: selectors._FileObject, callback: Callable[..., Any], *args: Any) -> None: ...

View File

@@ -5,7 +5,6 @@ import sys
from typing import Any, Awaitable, Callable, Dict, Generator, IO, List, Optional, Sequence, Tuple, TypeVar, Union, overload
from abc import ABCMeta, abstractmethod
from asyncio.futures import Future
from asyncio.coroutines import coroutine
from asyncio.protocols import BaseProtocol
from asyncio.tasks import Task
from asyncio.transports import BaseTransport
@@ -44,8 +43,7 @@ class AbstractServer:
def is_serving(self) -> bool: ...
async def start_serving(self) -> None: ...
async def serve_forever(self) -> None: ...
@coroutine
def wait_closed(self) -> Generator[Any, None, None]: ...
async def wait_closed(self) -> None: ...
class AbstractEventLoop(metaclass=ABCMeta):
slow_callback_duration: float = ...
@@ -70,8 +68,7 @@ class AbstractEventLoop(metaclass=ABCMeta):
def close(self) -> None: ...
if sys.version_info >= (3, 6):
@abstractmethod
@coroutine
def shutdown_asyncgens(self) -> Generator[Any, None, None]: ...
async def shutdown_asyncgens(self) -> None: ...
# Methods scheduling callbacks. All these return Handles.
@abstractmethod
def call_soon(self, callback: Callable[..., Any], *args: Any) -> Handle: ...
@@ -101,22 +98,19 @@ class AbstractEventLoop(metaclass=ABCMeta):
@abstractmethod
def call_soon_threadsafe(self, callback: Callable[..., Any], *args: Any) -> Handle: ...
@abstractmethod
@coroutine
def run_in_executor(self, executor: Any,
func: Callable[..., _T], *args: Any) -> Generator[Any, None, _T]: ...
async def run_in_executor(self, executor: Any,
func: Callable[..., _T], *args: Any) -> _T: ...
@abstractmethod
def set_default_executor(self, executor: Any) -> None: ...
# Network I/O methods returning Futures.
@abstractmethod
@coroutine
# TODO the "Tuple[Any, ...]" should be "Union[Tuple[str, int], Tuple[str, int, int, int]]" but that triggers
# https://github.com/python/mypy/issues/2509
def getaddrinfo(self, host: Optional[str], port: Union[str, int, None], *,
family: int = ..., type: int = ..., proto: int = ...,
flags: int = ...) -> Generator[Any, None, List[Tuple[int, int, int, str, Tuple[Any, ...]]]]: ...
async def getaddrinfo(self, host: Optional[str], port: Union[str, int, None], *,
family: int = ..., type: int = ..., proto: int = ...,
flags: int = ...) -> List[Tuple[int, int, int, str, Tuple[Any, ...]]]: ...
@abstractmethod
@coroutine
def getnameinfo(self, sockaddr: Tuple[Any, ...], flags: int = ...) -> Generator[Any, None, Tuple[str, int]]: ...
async def getnameinfo(self, sockaddr: Tuple[Any, ...], flags: int = ...) -> Tuple[str, int]: ...
if sys.version_info >= (3, 8):
@overload
@abstractmethod
@@ -172,16 +166,14 @@ class AbstractEventLoop(metaclass=ABCMeta):
else:
@overload
@abstractmethod
@coroutine
def create_connection(self, protocol_factory: _ProtocolFactory, host: str = ..., port: int = ..., *,
ssl: _SSLContext = ..., family: int = ..., proto: int = ..., flags: int = ..., sock: None = ...,
local_addr: Optional[str] = ..., server_hostname: Optional[str] = ...) -> Generator[Any, None, _TransProtPair]: ...
async def create_connection(self, protocol_factory: _ProtocolFactory, host: str = ..., port: int = ..., *,
ssl: _SSLContext = ..., family: int = ..., proto: int = ..., flags: int = ..., sock: None = ...,
local_addr: Optional[str] = ..., server_hostname: Optional[str] = ...) -> _TransProtPair: ...
@overload
@abstractmethod
@coroutine
def create_connection(self, protocol_factory: _ProtocolFactory, host: None = ..., port: None = ..., *,
ssl: _SSLContext = ..., family: int = ..., proto: int = ..., flags: int = ..., sock: socket,
local_addr: None = ..., server_hostname: Optional[str] = ...) -> Generator[Any, None, _TransProtPair]: ...
async def create_connection(self, protocol_factory: _ProtocolFactory, host: None = ..., port: None = ..., *,
ssl: _SSLContext = ..., family: int = ..., proto: int = ..., flags: int = ..., sock: socket,
local_addr: None = ..., server_hostname: Optional[str] = ...) -> _TransProtPair: ...
if sys.version_info >= (3, 7):
@abstractmethod
async def sock_sendfile(self, sock: socket, file: IO[bytes], offset: int = ..., count: Optional[int] = ..., *,
@@ -219,57 +211,47 @@ class AbstractEventLoop(metaclass=ABCMeta):
else:
@overload
@abstractmethod
@coroutine
def create_server(self, protocol_factory: _ProtocolFactory, host: Optional[Union[str, Sequence[str]]] = ..., port: int = ..., *,
family: int = ..., flags: int = ...,
sock: None = ..., backlog: int = ..., ssl: _SSLContext = ...,
reuse_address: Optional[bool] = ...,
reuse_port: Optional[bool] = ...) -> Generator[Any, None, AbstractServer]: ...
async def create_server(self, protocol_factory: _ProtocolFactory, host: Optional[Union[str, Sequence[str]]] = ..., port: int = ..., *,
family: int = ..., flags: int = ...,
sock: None = ..., backlog: int = ..., ssl: _SSLContext = ...,
reuse_address: Optional[bool] = ...,
reuse_port: Optional[bool] = ...) -> AbstractServer: ...
@overload
@abstractmethod
@coroutine
def create_server(self, protocol_factory: _ProtocolFactory, host: None = ..., port: None = ..., *,
family: int = ..., flags: int = ...,
sock: socket, backlog: int = ..., ssl: _SSLContext = ...,
reuse_address: Optional[bool] = ...,
reuse_port: Optional[bool] = ...) -> Generator[Any, None, AbstractServer]: ...
async def create_server(self, protocol_factory: _ProtocolFactory, host: None = ..., port: None = ..., *,
family: int = ..., flags: int = ...,
sock: socket, backlog: int = ..., ssl: _SSLContext = ...,
reuse_address: Optional[bool] = ...,
reuse_port: Optional[bool] = ...) -> AbstractServer: ...
@abstractmethod
@coroutine
def create_unix_connection(self, protocol_factory: _ProtocolFactory, path: str, *,
ssl: _SSLContext = ..., sock: Optional[socket] = ...,
server_hostname: str = ...) -> Generator[Any, None, _TransProtPair]: ...
async def create_unix_connection(self, protocol_factory: _ProtocolFactory, path: str, *,
ssl: _SSLContext = ..., sock: Optional[socket] = ...,
server_hostname: str = ...) -> _TransProtPair: ...
@abstractmethod
@coroutine
def create_unix_server(self, protocol_factory: _ProtocolFactory, path: str, *,
sock: Optional[socket] = ..., backlog: int = ..., ssl: _SSLContext = ...) -> Generator[Any, None, AbstractServer]: ...
async def create_unix_server(self, protocol_factory: _ProtocolFactory, path: str, *,
sock: Optional[socket] = ..., backlog: int = ..., ssl: _SSLContext = ...) -> AbstractServer: ...
@abstractmethod
@coroutine
def connect_accepted_socket(self, protocol_factory: _ProtocolFactory, sock: socket, *, ssl: _SSLContext = ...) -> Generator[Any, None, _TransProtPair]: ...
async def connect_accepted_socket(self, protocol_factory: _ProtocolFactory, sock: socket, *, ssl: _SSLContext = ...) -> _TransProtPair: ...
@abstractmethod
@coroutine
def create_datagram_endpoint(self, protocol_factory: _ProtocolFactory,
local_addr: Optional[Tuple[str, int]] = ..., remote_addr: Optional[Tuple[str, int]] = ..., *,
family: int = ..., proto: int = ..., flags: int = ...,
reuse_address: Optional[bool] = ..., reuse_port: Optional[bool] = ...,
allow_broadcast: Optional[bool] = ...,
sock: Optional[socket] = ...) -> Generator[Any, None, _TransProtPair]: ...
async def create_datagram_endpoint(self, protocol_factory: _ProtocolFactory,
local_addr: Optional[Tuple[str, int]] = ..., remote_addr: Optional[Tuple[str, int]] = ..., *,
family: int = ..., proto: int = ..., flags: int = ...,
reuse_address: Optional[bool] = ..., reuse_port: Optional[bool] = ...,
allow_broadcast: Optional[bool] = ...,
sock: Optional[socket] = ...) -> _TransProtPair: ...
# Pipes and subprocesses.
@abstractmethod
@coroutine
def connect_read_pipe(self, protocol_factory: _ProtocolFactory, pipe: Any) -> Generator[Any, None, _TransProtPair]: ...
async def connect_read_pipe(self, protocol_factory: _ProtocolFactory, pipe: Any) -> _TransProtPair: ...
@abstractmethod
@coroutine
def connect_write_pipe(self, protocol_factory: _ProtocolFactory, pipe: Any) -> Generator[Any, None, _TransProtPair]: ...
async def connect_write_pipe(self, protocol_factory: _ProtocolFactory, pipe: Any) -> _TransProtPair: ...
@abstractmethod
@coroutine
def subprocess_shell(self, protocol_factory: _ProtocolFactory, cmd: Union[bytes, str], *, stdin: Any = ...,
stdout: Any = ..., stderr: Any = ...,
**kwargs: Any) -> Generator[Any, None, _TransProtPair]: ...
async def subprocess_shell(self, protocol_factory: _ProtocolFactory, cmd: Union[bytes, str], *, stdin: Any = ...,
stdout: Any = ..., stderr: Any = ...,
**kwargs: Any) -> _TransProtPair: ...
@abstractmethod
@coroutine
def subprocess_exec(self, protocol_factory: _ProtocolFactory, *args: Any, stdin: Any = ...,
stdout: Any = ..., stderr: Any = ...,
**kwargs: Any) -> Generator[Any, None, _TransProtPair]: ...
async def subprocess_exec(self, protocol_factory: _ProtocolFactory, *args: Any, stdin: Any = ...,
stdout: Any = ..., stderr: Any = ...,
**kwargs: Any) -> _TransProtPair: ...
@abstractmethod
def add_reader(self, fd: selectors._FileObject, callback: Callable[..., Any], *args: Any) -> None: ...
@abstractmethod

View File

@@ -1,6 +1,5 @@
from typing import Any, Callable, Generator, Type, TypeVar, Union, Optional, Awaitable
from typing import Any, Callable, Type, TypeVar, Union, Optional, Awaitable
from .coroutines import coroutine
from .events import AbstractEventLoop
from .futures import Future
from types import TracebackType
@@ -22,8 +21,7 @@ class _ContextManagerMixin(Future[_ContextManager]):
class Lock(_ContextManagerMixin):
def __init__(self, *, loop: Optional[AbstractEventLoop] = ...) -> None: ...
def locked(self) -> bool: ...
@coroutine
def acquire(self) -> Generator[Any, None, bool]: ...
async def acquire(self) -> bool: ...
def release(self) -> None: ...
class Event:
@@ -31,27 +29,22 @@ class Event:
def is_set(self) -> bool: ...
def set(self) -> None: ...
def clear(self) -> None: ...
@coroutine
def wait(self) -> Generator[Any, None, bool]: ...
async def wait(self) -> bool: ...
class Condition(_ContextManagerMixin):
def __init__(self, lock: Optional[Lock] = ..., *, loop: Optional[AbstractEventLoop] = ...) -> None: ...
def locked(self) -> bool: ...
@coroutine
def acquire(self) -> Generator[Any, None, bool]: ...
async def acquire(self) -> bool: ...
def release(self) -> None: ...
@coroutine
def wait(self) -> Generator[Any, None, bool]: ...
@coroutine
def wait_for(self, predicate: Callable[[], _T]) -> Generator[Any, None, _T]: ...
async def wait(self) -> bool: ...
async def wait_for(self, predicate: Callable[[], _T]) -> _T: ...
def notify(self, n: int = ...) -> None: ...
def notify_all(self) -> None: ...
class Semaphore(_ContextManagerMixin):
def __init__(self, value: int = ..., *, loop: Optional[AbstractEventLoop] = ...) -> None: ...
def locked(self) -> bool: ...
@coroutine
def acquire(self) -> Generator[Any, None, bool]: ...
async def acquire(self) -> bool: ...
def release(self) -> None: ...
class BoundedSemaphore(Semaphore):

View File

@@ -1,7 +1,6 @@
import sys
from asyncio import coroutine
from socket import socket
from typing import Any, Generator, Mapping, Optional, Union
from typing import Any, Mapping, Optional, Union
from . import base_events, constants, events, futures, streams, transports
@@ -74,10 +73,8 @@ class BaseProactorEventLoop(base_events.BaseEventLoop):
start_serving: bool = ...,
) -> events.AbstractServer: ...
else:
@coroutine
def create_unix_connection(self, protocol_factory: events._ProtocolFactory, path: str, *,
ssl: events._SSLContext = ..., sock: Optional[socket] = ...,
server_hostname: str = ...) -> Generator[Any, None, events._TransProtPair]: ...
@coroutine
def create_unix_server(self, protocol_factory: events._ProtocolFactory, path: str, *,
sock: Optional[socket] = ..., backlog: int = ..., ssl: events._SSLContext = ...) -> Generator[Any, None, events.AbstractServer]: ...
async def create_unix_connection(self, protocol_factory: events._ProtocolFactory, path: str, *,
ssl: events._SSLContext = ..., sock: Optional[socket] = ...,
server_hostname: str = ...) -> events._TransProtPair: ...
async def create_unix_server(self, protocol_factory: events._ProtocolFactory, path: str, *,
sock: Optional[socket] = ..., backlog: int = ..., ssl: events._SSLContext = ...) -> events.AbstractServer: ...

View File

@@ -1,6 +1,5 @@
from asyncio.events import AbstractEventLoop
from .coroutines import coroutine
from typing import Any, Generator, Generic, TypeVar, Optional
from typing import Generic, TypeVar, Optional
class QueueEmpty(Exception): ...
class QueueFull(Exception): ...
@@ -22,14 +21,11 @@ class Queue(Generic[_T]):
def maxsize(self) -> int: ...
def empty(self) -> bool: ...
def full(self) -> bool: ...
@coroutine
def put(self, item: _T) -> Generator[Any, None, None]: ...
async def put(self, item: _T) -> None: ...
def put_nowait(self, item: _T) -> None: ...
@coroutine
def get(self) -> Generator[Any, None, _T]: ...
async def get(self) -> _T: ...
def get_nowait(self) -> _T: ...
@coroutine
def join(self) -> Generator[Any, None, bool]: ...
async def join(self) -> bool: ...
def task_done(self) -> None: ...

View File

@@ -1,8 +1,7 @@
import selectors
import sys
from asyncio import coroutine
from socket import socket
from typing import Any, Generator, Optional, Union
from typing import Optional, Union
from . import base_events, events
@@ -38,10 +37,8 @@ class BaseSelectorEventLoop(base_events.BaseEventLoop):
start_serving: bool = ...,
) -> events.AbstractServer: ...
else:
@coroutine
def create_unix_connection(self, protocol_factory: events._ProtocolFactory, path: str, *,
ssl: events._SSLContext = ..., sock: Optional[socket] = ...,
server_hostname: str = ...) -> Generator[Any, None, events._TransProtPair]: ...
@coroutine
def create_unix_server(self, protocol_factory: events._ProtocolFactory, path: str, *,
sock: Optional[socket] = ..., backlog: int = ..., ssl: events._SSLContext = ...) -> Generator[Any, None, events.AbstractServer]: ...
async def create_unix_connection(self, protocol_factory: events._ProtocolFactory, path: str, *,
ssl: events._SSLContext = ..., sock: Optional[socket] = ...,
server_hostname: str = ...) -> events._TransProtPair: ...
async def create_unix_server(self, protocol_factory: events._ProtocolFactory, path: str, *,
sock: Optional[socket] = ..., backlog: int = ..., ssl: events._SSLContext = ...) -> events.AbstractServer: ...

View File

@@ -1,7 +1,6 @@
import sys
from typing import Any, Awaitable, Callable, Generator, Iterable, Optional, Tuple, Union
from typing import Any, Awaitable, Callable, Iterable, Optional, Tuple, Union
from . import coroutines
from . import events
from . import protocols
from . import transports
@@ -18,8 +17,7 @@ if sys.version_info < (3, 8):
consumed: int
def __init__(self, message: str, consumed: int) -> None: ...
@coroutines.coroutine
def open_connection(
async def open_connection(
host: str = ...,
port: Union[int, str] = ...,
*,
@@ -27,10 +25,9 @@ def open_connection(
limit: int = ...,
ssl_handshake_timeout: Optional[float] = ...,
**kwds: Any
) -> Generator[Any, None, Tuple[StreamReader, StreamWriter]]: ...
) -> Tuple[StreamReader, StreamWriter]: ...
@coroutines.coroutine
def start_server(
async def start_server(
client_connected_cb: _ClientConnectedCallback,
host: Optional[str] = ...,
port: Optional[Union[int, str]] = ...,
@@ -39,7 +36,7 @@ def start_server(
limit: int = ...,
ssl_handshake_timeout: Optional[float] = ...,
**kwds: Any
) -> Generator[Any, None, events.AbstractServer]: ...
) -> events.AbstractServer: ...
if sys.platform != 'win32':
if sys.version_info >= (3, 7):
@@ -48,23 +45,21 @@ if sys.platform != 'win32':
else:
_PathType = str
@coroutines.coroutine
def open_unix_connection(
async def open_unix_connection(
path: _PathType = ...,
*,
loop: Optional[events.AbstractEventLoop] = ...,
limit: int = ...,
**kwds: Any
) -> Generator[Any, None, Tuple[StreamReader, StreamWriter]]: ...
) -> Tuple[StreamReader, StreamWriter]: ...
@coroutines.coroutine
def start_unix_server(
async def start_unix_server(
client_connected_cb: _ClientConnectedCallback,
path: _PathType = ...,
*,
loop: Optional[events.AbstractEventLoop] = ...,
limit: int = ...,
**kwds: Any) -> Generator[Any, None, events.AbstractServer]: ...
**kwds: Any) -> events.AbstractServer: ...
class FlowControlMixin(protocols.Protocol): ...
@@ -93,11 +88,9 @@ class StreamWriter:
def close(self) -> None: ...
if sys.version_info >= (3, 7):
def is_closing(self) -> bool: ...
@coroutines.coroutine
def wait_closed(self) -> None: ...
async def wait_closed(self) -> None: ...
def get_extra_info(self, name: str, default: Any = ...) -> Any: ...
@coroutines.coroutine
def drain(self) -> Generator[Any, None, None]: ...
async def drain(self) -> None: ...
class StreamReader:
def __init__(self,
@@ -109,11 +102,7 @@ class StreamReader:
def feed_eof(self) -> None: ...
def at_eof(self) -> bool: ...
def feed_data(self, data: bytes) -> None: ...
@coroutines.coroutine
def readline(self) -> Generator[Any, None, bytes]: ...
@coroutines.coroutine
def readuntil(self, separator: bytes = ...) -> Generator[Any, None, bytes]: ...
@coroutines.coroutine
def read(self, n: int = ...) -> Generator[Any, None, bytes]: ...
@coroutines.coroutine
def readexactly(self, n: int) -> Generator[Any, None, bytes]: ...
async def readline(self) -> bytes: ...
async def readuntil(self, separator: bytes = ...) -> bytes: ...
async def read(self, n: int = ...) -> bytes: ...
async def readexactly(self, n: int) -> bytes: ...

View File

@@ -2,8 +2,7 @@ from asyncio import events
from asyncio import protocols
from asyncio import streams
from asyncio import transports
from asyncio.coroutines import coroutine
from typing import Any, Generator, Optional, Text, Tuple, Union, IO
from typing import Any, Optional, Text, Tuple, Union, IO
PIPE: int
STDOUT: int
@@ -32,17 +31,14 @@ class Process:
loop: events.AbstractEventLoop) -> None: ...
@property
def returncode(self) -> int: ...
@coroutine
def wait(self) -> Generator[Any, None, int]: ...
async def wait(self) -> int: ...
def send_signal(self, signal: int) -> None: ...
def terminate(self) -> None: ...
def kill(self) -> None: ...
@coroutine
def communicate(self, input: Optional[bytes] = ...) -> Generator[Any, None, Tuple[bytes, bytes]]: ...
async def communicate(self, input: Optional[bytes] = ...) -> Tuple[bytes, bytes]: ...
@coroutine
def create_subprocess_shell(
async def create_subprocess_shell(
*Args: Union[str, bytes], # Union used instead of AnyStr due to mypy issue #1236
stdin: Union[int, IO[Any], None] = ...,
stdout: Union[int, IO[Any], None] = ...,
@@ -50,10 +46,9 @@ def create_subprocess_shell(
loop: events.AbstractEventLoop = ...,
limit: int = ...,
**kwds: Any
) -> Generator[Any, None, Process]: ...
) -> Process: ...
@coroutine
def create_subprocess_exec(
async def create_subprocess_exec(
program: Union[str, bytes], # Union used instead of AnyStr due to mypy issue #1236
*args: Any,
stdin: Union[int, IO[Any], None] = ...,
@@ -62,4 +57,4 @@ def create_subprocess_exec(
loop: events.AbstractEventLoop = ...,
limit: int = ...,
**kwds: Any
) -> Generator[Any, None, Process]: ...
) -> Process: ...