mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-16 00:37:10 +08:00
Move asyncio from 3.4 to 3 (#2307)
This commit is contained in:
committed by
Guido van Rossum
parent
d4c15011e4
commit
2a36b4cf01
110
stdlib/3/asyncio/__init__.pyi
Normal file
110
stdlib/3/asyncio/__init__.pyi
Normal file
@@ -0,0 +1,110 @@
|
||||
import sys
|
||||
from typing import List, Type
|
||||
|
||||
from asyncio.coroutines import (
|
||||
coroutine as coroutine,
|
||||
iscoroutinefunction as iscoroutinefunction,
|
||||
iscoroutine as iscoroutine,
|
||||
)
|
||||
from asyncio.protocols import (
|
||||
BaseProtocol as BaseProtocol,
|
||||
Protocol as Protocol,
|
||||
DatagramProtocol as DatagramProtocol,
|
||||
SubprocessProtocol as SubprocessProtocol,
|
||||
)
|
||||
from asyncio.streams import (
|
||||
StreamReader as StreamReader,
|
||||
StreamWriter as StreamWriter,
|
||||
StreamReaderProtocol as StreamReaderProtocol,
|
||||
open_connection as open_connection,
|
||||
start_server as start_server,
|
||||
IncompleteReadError as IncompleteReadError,
|
||||
LimitOverrunError as LimitOverrunError,
|
||||
)
|
||||
from asyncio.subprocess import (
|
||||
create_subprocess_exec as create_subprocess_exec,
|
||||
create_subprocess_shell as create_subprocess_shell,
|
||||
)
|
||||
from asyncio.transports import (
|
||||
BaseTransport as BaseTransport,
|
||||
ReadTransport as ReadTransport,
|
||||
WriteTransport as WriteTransport,
|
||||
Transport as Transport,
|
||||
DatagramTransport as DatagramTransport,
|
||||
SubprocessTransport as SubprocessTransport,
|
||||
)
|
||||
from asyncio.futures import (
|
||||
Future as Future,
|
||||
CancelledError as CancelledError,
|
||||
TimeoutError as TimeoutError,
|
||||
InvalidStateError as InvalidStateError,
|
||||
wrap_future as wrap_future,
|
||||
)
|
||||
from asyncio.tasks import (
|
||||
FIRST_COMPLETED as FIRST_COMPLETED,
|
||||
FIRST_EXCEPTION as FIRST_EXCEPTION,
|
||||
ALL_COMPLETED as ALL_COMPLETED,
|
||||
as_completed as as_completed,
|
||||
ensure_future as ensure_future,
|
||||
gather as gather,
|
||||
run_coroutine_threadsafe as run_coroutine_threadsafe,
|
||||
shield as shield,
|
||||
sleep as sleep,
|
||||
wait as wait,
|
||||
wait_for as wait_for,
|
||||
Task as Task,
|
||||
)
|
||||
from asyncio.events import (
|
||||
AbstractEventLoopPolicy as AbstractEventLoopPolicy,
|
||||
AbstractEventLoop as AbstractEventLoop,
|
||||
AbstractServer as AbstractServer,
|
||||
Handle as Handle,
|
||||
TimerHandle as TimerHandle,
|
||||
get_event_loop_policy as get_event_loop_policy,
|
||||
set_event_loop_policy as set_event_loop_policy,
|
||||
get_event_loop as get_event_loop,
|
||||
set_event_loop as set_event_loop,
|
||||
new_event_loop as new_event_loop,
|
||||
get_child_watcher as get_child_watcher,
|
||||
set_child_watcher as set_child_watcher,
|
||||
)
|
||||
from asyncio.queues import (
|
||||
Queue as Queue,
|
||||
PriorityQueue as PriorityQueue,
|
||||
LifoQueue as LifoQueue,
|
||||
QueueFull as QueueFull,
|
||||
QueueEmpty as QueueEmpty,
|
||||
)
|
||||
from asyncio.locks import (
|
||||
Lock as Lock,
|
||||
Event as Event,
|
||||
Condition as Condition,
|
||||
Semaphore as Semaphore,
|
||||
BoundedSemaphore as BoundedSemaphore,
|
||||
)
|
||||
|
||||
if sys.version_info < (3, 5):
|
||||
from asyncio.queues import JoinableQueue as JoinableQueue
|
||||
else:
|
||||
from asyncio.futures import isfuture as isfuture
|
||||
from asyncio.events import (
|
||||
_set_running_loop as _set_running_loop,
|
||||
_get_running_loop as _get_running_loop,
|
||||
)
|
||||
if sys.platform != 'win32':
|
||||
from asyncio.streams import (
|
||||
open_unix_connection as open_unix_connection,
|
||||
start_unix_server as start_unix_server,
|
||||
)
|
||||
|
||||
# TODO: It should be possible to instantiate these classes, but mypy
|
||||
# currently disallows this.
|
||||
# See https://github.com/python/mypy/issues/1843
|
||||
SelectorEventLoop = ... # type: Type[AbstractEventLoop]
|
||||
if sys.platform == 'win32':
|
||||
ProactorEventLoop = ... # type: Type[AbstractEventLoop]
|
||||
DefaultEventLoopPolicy = ... # type: Type[AbstractEventLoopPolicy]
|
||||
|
||||
# TODO: AbstractChildWatcher (UNIX only)
|
||||
|
||||
__all__: List[str]
|
||||
9
stdlib/3/asyncio/coroutines.pyi
Normal file
9
stdlib/3/asyncio/coroutines.pyi
Normal file
@@ -0,0 +1,9 @@
|
||||
from typing import Any, Callable, Generator, List, TypeVar
|
||||
|
||||
__all__: List[str]
|
||||
|
||||
_F = TypeVar('_F', bound=Callable[..., Any])
|
||||
|
||||
def coroutine(func: _F) -> _F: ...
|
||||
def iscoroutinefunction(func: Callable[..., Any]) -> bool: ...
|
||||
def iscoroutine(obj: Any) -> bool: ...
|
||||
224
stdlib/3/asyncio/events.pyi
Normal file
224
stdlib/3/asyncio/events.pyi
Normal file
@@ -0,0 +1,224 @@
|
||||
import selectors
|
||||
from socket import socket
|
||||
import ssl
|
||||
import sys
|
||||
from typing import Any, Awaitable, Callable, Dict, Generator, 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
|
||||
|
||||
__all__: List[str]
|
||||
|
||||
_T = TypeVar('_T')
|
||||
_Context = Dict[str, Any]
|
||||
_ExceptionHandler = Callable[[AbstractEventLoop, _Context], Any]
|
||||
_ProtocolFactory = Callable[[], BaseProtocol]
|
||||
_SSLContext = Union[bool, None, ssl.SSLContext]
|
||||
_TransProtPair = Tuple[BaseTransport, BaseProtocol]
|
||||
|
||||
class Handle:
|
||||
_cancelled = False
|
||||
_args = ... # type: List[Any]
|
||||
def __init__(self, callback: Callable[..., Any], args: List[Any],
|
||||
loop: AbstractEventLoop) -> None: ...
|
||||
def __repr__(self) -> str: ...
|
||||
def cancel(self) -> None: ...
|
||||
def _run(self) -> None: ...
|
||||
|
||||
class TimerHandle(Handle):
|
||||
def __init__(self, when: float, callback: Callable[..., Any], args: List[Any],
|
||||
loop: AbstractEventLoop) -> None: ...
|
||||
def __hash__(self) -> int: ...
|
||||
|
||||
class AbstractServer:
|
||||
def close(self) -> None: ...
|
||||
@coroutine
|
||||
def wait_closed(self) -> Generator[Any, None, None]: ...
|
||||
|
||||
class AbstractEventLoop(metaclass=ABCMeta):
|
||||
@abstractmethod
|
||||
def run_forever(self) -> None: ...
|
||||
|
||||
# Can't use a union, see mypy issue # 1873.
|
||||
@overload
|
||||
@abstractmethod
|
||||
def run_until_complete(self, future: Generator[Any, None, _T]) -> _T: ...
|
||||
@overload
|
||||
@abstractmethod
|
||||
def run_until_complete(self, future: Awaitable[_T]) -> _T: ...
|
||||
|
||||
@abstractmethod
|
||||
def stop(self) -> None: ...
|
||||
@abstractmethod
|
||||
def is_running(self) -> bool: ...
|
||||
@abstractmethod
|
||||
def is_closed(self) -> bool: ...
|
||||
@abstractmethod
|
||||
def close(self) -> None: ...
|
||||
if sys.version_info >= (3, 6):
|
||||
@abstractmethod
|
||||
@coroutine
|
||||
def shutdown_asyncgens(self) -> Generator[Any, None, None]: ...
|
||||
# Methods scheduling callbacks. All these return Handles.
|
||||
@abstractmethod
|
||||
def call_soon(self, callback: Callable[..., Any], *args: Any) -> Handle: ...
|
||||
@abstractmethod
|
||||
def call_later(self, delay: Union[int, float], callback: Callable[..., Any], *args: Any) -> Handle: ...
|
||||
@abstractmethod
|
||||
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[Awaitable[_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: ...
|
||||
@abstractmethod
|
||||
@coroutine
|
||||
def run_in_executor(self, executor: Any,
|
||||
func: Callable[..., _T], *args: Any) -> Generator[Any, None, _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, ...]]]]: ...
|
||||
@abstractmethod
|
||||
@coroutine
|
||||
def getnameinfo(self, sockaddr: tuple, flags: int = ...) -> Generator[Any, None, Tuple[str, int]]: ...
|
||||
@abstractmethod
|
||||
@coroutine
|
||||
def create_connection(self, protocol_factory: _ProtocolFactory, host: str = ..., port: int = ..., *,
|
||||
ssl: _SSLContext = ..., family: int = ..., proto: int = ..., flags: int = ..., sock: Optional[socket] = ...,
|
||||
local_addr: str = ..., server_hostname: str = ...) -> Generator[Any, None, _TransProtPair]: ...
|
||||
@abstractmethod
|
||||
@coroutine
|
||||
def create_server(self, protocol_factory: _ProtocolFactory, host: Union[str, Sequence[str]] = ..., port: int = ..., *,
|
||||
family: int = ..., flags: int = ...,
|
||||
sock: Optional[socket] = ..., backlog: int = ..., ssl: _SSLContext = ...,
|
||||
reuse_address: Optional[bool] = ...,
|
||||
reuse_port: Optional[bool] = ...) -> Generator[Any, None, 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]: ...
|
||||
@abstractmethod
|
||||
@coroutine
|
||||
def create_unix_server(self, protocol_factory: _ProtocolFactory, path: str, *,
|
||||
sock: Optional[socket] = ..., backlog: int = ..., ssl: _SSLContext = ...) -> Generator[Any, None, AbstractServer]: ...
|
||||
@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]: ...
|
||||
@abstractmethod
|
||||
@coroutine
|
||||
def connect_accepted_socket(self, protocol_factory: _ProtocolFactory, sock: socket, *, ssl: _SSLContext = ...) -> Generator[Any, None, _TransProtPair]: ...
|
||||
# Pipes and subprocesses.
|
||||
@abstractmethod
|
||||
@coroutine
|
||||
def connect_read_pipe(self, protocol_factory: _ProtocolFactory, pipe: Any) -> Generator[Any, None, _TransProtPair]: ...
|
||||
@abstractmethod
|
||||
@coroutine
|
||||
def connect_write_pipe(self, protocol_factory: _ProtocolFactory, pipe: Any) -> Generator[Any, None, _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]: ...
|
||||
@abstractmethod
|
||||
@coroutine
|
||||
def subprocess_exec(self, protocol_factory: _ProtocolFactory, *args: Any, stdin: Any = ...,
|
||||
stdout: Any = ..., stderr: Any = ...,
|
||||
**kwargs: Any) -> Generator[Any, None, _TransProtPair]: ...
|
||||
@abstractmethod
|
||||
def add_reader(self, fd: selectors._FileObject, callback: Callable[..., Any], *args: Any) -> None: ...
|
||||
@abstractmethod
|
||||
def remove_reader(self, fd: selectors._FileObject) -> None: ...
|
||||
@abstractmethod
|
||||
def add_writer(self, fd: selectors._FileObject, callback: Callable[..., Any], *args: Any) -> None: ...
|
||||
@abstractmethod
|
||||
def remove_writer(self, fd: selectors._FileObject) -> None: ...
|
||||
# Completion based I/O methods returning Futures.
|
||||
@abstractmethod
|
||||
@coroutine
|
||||
def sock_recv(self, sock: socket, nbytes: int) -> Generator[Any, None, bytes]: ...
|
||||
@abstractmethod
|
||||
@coroutine
|
||||
def sock_sendall(self, sock: socket, data: bytes) -> Generator[Any, None, None]: ...
|
||||
@abstractmethod
|
||||
@coroutine
|
||||
def sock_connect(self, sock: socket, address: str) -> Generator[Any, None, None]: ...
|
||||
@abstractmethod
|
||||
@coroutine
|
||||
def sock_accept(self, sock: socket) -> Generator[Any, None, Tuple[socket, Any]]: ...
|
||||
# Signal handling.
|
||||
@abstractmethod
|
||||
def add_signal_handler(self, sig: int, callback: Callable[..., Any], *args: Any) -> None: ...
|
||||
@abstractmethod
|
||||
def remove_signal_handler(self, sig: int) -> None: ...
|
||||
# Error handlers.
|
||||
@abstractmethod
|
||||
def set_exception_handler(self, handler: _ExceptionHandler) -> None: ...
|
||||
@abstractmethod
|
||||
def get_exception_handler(self) -> _ExceptionHandler: ...
|
||||
@abstractmethod
|
||||
def default_exception_handler(self, context: _Context) -> None: ...
|
||||
@abstractmethod
|
||||
def call_exception_handler(self, context: _Context) -> None: ...
|
||||
# Debug flag management.
|
||||
@abstractmethod
|
||||
def get_debug(self) -> bool: ...
|
||||
@abstractmethod
|
||||
def set_debug(self, enabled: bool) -> None: ...
|
||||
|
||||
class AbstractEventLoopPolicy(metaclass=ABCMeta):
|
||||
@abstractmethod
|
||||
def get_event_loop(self) -> AbstractEventLoop: ...
|
||||
@abstractmethod
|
||||
def set_event_loop(self, loop: AbstractEventLoop) -> None: ...
|
||||
@abstractmethod
|
||||
def new_event_loop(self) -> AbstractEventLoop: ...
|
||||
# Child processes handling (Unix only).
|
||||
@abstractmethod
|
||||
def get_child_watcher(self) -> Any: ... # TODO: unix_events.AbstractChildWatcher
|
||||
@abstractmethod
|
||||
def set_child_watcher(self, watcher: Any) -> None: ... # TODO: unix_events.AbstractChildWatcher
|
||||
|
||||
class BaseDefaultEventLoopPolicy(AbstractEventLoopPolicy, metaclass=ABCMeta):
|
||||
def __init__(self) -> None: ...
|
||||
def get_event_loop(self) -> AbstractEventLoop: ...
|
||||
def set_event_loop(self, loop: AbstractEventLoop) -> None: ...
|
||||
def new_event_loop(self) -> AbstractEventLoop: ...
|
||||
|
||||
def get_event_loop_policy() -> AbstractEventLoopPolicy: ...
|
||||
def set_event_loop_policy(policy: AbstractEventLoopPolicy) -> None: ...
|
||||
|
||||
def get_event_loop() -> AbstractEventLoop: ...
|
||||
def set_event_loop(loop: AbstractEventLoop) -> None: ...
|
||||
def new_event_loop() -> AbstractEventLoop: ...
|
||||
|
||||
def get_child_watcher() -> Any: ... # TODO: unix_events.AbstractChildWatcher
|
||||
def set_child_watcher(watcher: Any) -> None: ... # TODO: unix_events.AbstractChildWatcher
|
||||
|
||||
def _set_running_loop(loop: AbstractEventLoop) -> None: ...
|
||||
def _get_running_loop() -> AbstractEventLoop: ...
|
||||
52
stdlib/3/asyncio/futures.pyi
Normal file
52
stdlib/3/asyncio/futures.pyi
Normal file
@@ -0,0 +1,52 @@
|
||||
import sys
|
||||
from typing import Any, Union, Callable, TypeVar, Type, List, Generic, Iterable, Generator, Awaitable
|
||||
from .events import AbstractEventLoop
|
||||
from concurrent.futures import (
|
||||
CancelledError as CancelledError,
|
||||
TimeoutError as TimeoutError,
|
||||
Future as _ConcurrentFuture,
|
||||
Error,
|
||||
)
|
||||
|
||||
__all__: List[str]
|
||||
|
||||
_T = TypeVar('_T')
|
||||
_S = TypeVar('_S', bound=Future)
|
||||
|
||||
class InvalidStateError(Error): ...
|
||||
|
||||
class _TracebackLogger:
|
||||
exc = ... # type: BaseException
|
||||
tb = ... # type: List[str]
|
||||
def __init__(self, exc: Any, loop: AbstractEventLoop) -> None: ...
|
||||
def activate(self) -> None: ...
|
||||
def clear(self) -> None: ...
|
||||
def __del__(self) -> None: ...
|
||||
|
||||
if sys.version_info >= (3, 5):
|
||||
def isfuture(obj: object) -> bool: ...
|
||||
|
||||
class Future(Awaitable[_T], Iterable[_T]):
|
||||
_state = ... # type: str
|
||||
_exception = ... # type: BaseException
|
||||
_blocking = False
|
||||
_log_traceback = False
|
||||
_tb_logger = ... # type: Type[_TracebackLogger]
|
||||
def __init__(self, *, loop: AbstractEventLoop = ...) -> None: ...
|
||||
def __repr__(self) -> str: ...
|
||||
def __del__(self) -> None: ...
|
||||
def cancel(self) -> bool: ...
|
||||
def _schedule_callbacks(self) -> None: ...
|
||||
def cancelled(self) -> bool: ...
|
||||
def done(self) -> bool: ...
|
||||
def result(self) -> _T: ...
|
||||
def exception(self) -> BaseException: ...
|
||||
def add_done_callback(self: _S, fn: Callable[[_S], Any]) -> None: ...
|
||||
def remove_done_callback(self: _S, fn: Callable[[_S], Any]) -> int: ...
|
||||
def set_result(self, result: _T) -> None: ...
|
||||
def set_exception(self, exception: Union[type, BaseException]) -> None: ...
|
||||
def _copy_state(self, other: Any) -> None: ...
|
||||
def __iter__(self) -> Generator[Any, None, _T]: ...
|
||||
def __await__(self) -> Generator[Any, None, _T]: ...
|
||||
|
||||
def wrap_future(f: Union[_ConcurrentFuture[_T], Future[_T]]) -> Future[_T]: ...
|
||||
60
stdlib/3/asyncio/locks.pyi
Normal file
60
stdlib/3/asyncio/locks.pyi
Normal file
@@ -0,0 +1,60 @@
|
||||
from typing import Any, Callable, Generator, Iterable, Iterator, List, Type, TypeVar, Union, Optional, Awaitable
|
||||
|
||||
from .coroutines import coroutine
|
||||
from .events import AbstractEventLoop
|
||||
from .futures import Future
|
||||
from types import TracebackType
|
||||
|
||||
_T = TypeVar('_T')
|
||||
|
||||
__all__: List[str]
|
||||
|
||||
class _ContextManager:
|
||||
def __init__(self, lock: Union[Lock, Semaphore]) -> None: ...
|
||||
def __enter__(self) -> object: ...
|
||||
def __exit__(self, *args: Any) -> None: ...
|
||||
|
||||
class _ContextManagerMixin(Future[_ContextManager]):
|
||||
# Apparently this exists to *prohibit* use as a context manager.
|
||||
def __enter__(self) -> object: ...
|
||||
def __exit__(self, *args: Any) -> None: ...
|
||||
def __aenter__(self) -> Awaitable[None]: ...
|
||||
def __aexit__(self, exc_type: Optional[Type[BaseException]], exc: Optional[BaseException], tb: Optional[TracebackType]) -> Awaitable[None]: ...
|
||||
|
||||
class Lock(_ContextManagerMixin):
|
||||
def __init__(self, *, loop: Optional[AbstractEventLoop] = ...) -> None: ...
|
||||
def locked(self) -> bool: ...
|
||||
@coroutine
|
||||
def acquire(self) -> Generator[Any, None, bool]: ...
|
||||
def release(self) -> None: ...
|
||||
|
||||
class Event:
|
||||
def __init__(self, *, loop: Optional[AbstractEventLoop] = ...) -> None: ...
|
||||
def is_set(self) -> bool: ...
|
||||
def set(self) -> None: ...
|
||||
def clear(self) -> None: ...
|
||||
@coroutine
|
||||
def wait(self) -> Generator[Any, None, 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]: ...
|
||||
def release(self) -> None: ...
|
||||
@coroutine
|
||||
def wait(self) -> Generator[Any, None, bool]: ...
|
||||
@coroutine
|
||||
def wait_for(self, predicate: Callable[[], _T]) -> Generator[Any, None, _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]: ...
|
||||
def release(self) -> None: ...
|
||||
|
||||
class BoundedSemaphore(Semaphore):
|
||||
def __init__(self, value: int = ..., *, loop: Optional[AbstractEventLoop] = ...) -> None: ...
|
||||
24
stdlib/3/asyncio/protocols.pyi
Normal file
24
stdlib/3/asyncio/protocols.pyi
Normal file
@@ -0,0 +1,24 @@
|
||||
from asyncio import transports
|
||||
from typing import List, Text, Tuple, Union
|
||||
|
||||
__all__: List[str]
|
||||
|
||||
|
||||
class BaseProtocol:
|
||||
def connection_made(self, transport: transports.BaseTransport) -> None: ...
|
||||
def connection_lost(self, exc: Exception) -> None: ...
|
||||
def pause_writing(self) -> None: ...
|
||||
def resume_writing(self) -> None: ...
|
||||
|
||||
class Protocol(BaseProtocol):
|
||||
def data_received(self, data: bytes) -> None: ...
|
||||
def eof_received(self) -> bool: ...
|
||||
|
||||
class DatagramProtocol(BaseProtocol):
|
||||
def datagram_received(self, data: Union[bytes, Text], addr: Tuple[str, int]) -> None: ...
|
||||
def error_received(self, exc: Exception) -> None: ...
|
||||
|
||||
class SubprocessProtocol(BaseProtocol):
|
||||
def pipe_data_received(self, fd: int, data: Union[bytes, Text]) -> None: ...
|
||||
def pipe_connection_lost(self, fd: int, exc: Exception) -> None: ...
|
||||
def process_exited(self) -> None: ...
|
||||
50
stdlib/3/asyncio/queues.pyi
Normal file
50
stdlib/3/asyncio/queues.pyi
Normal file
@@ -0,0 +1,50 @@
|
||||
import sys
|
||||
from asyncio.events import AbstractEventLoop
|
||||
from .coroutines import coroutine
|
||||
from .futures import Future
|
||||
from typing import Any, Generator, Generic, List, TypeVar
|
||||
|
||||
__all__: List[str]
|
||||
|
||||
|
||||
class QueueEmpty(Exception): ...
|
||||
class QueueFull(Exception): ...
|
||||
|
||||
_T = TypeVar('_T')
|
||||
|
||||
class Queue(Generic[_T]):
|
||||
def __init__(self, maxsize: int = ..., *, loop: AbstractEventLoop = ...) -> None: ...
|
||||
def _init(self, maxsize: int) -> None: ...
|
||||
def _get(self) -> _T: ...
|
||||
def _put(self, item: _T) -> None: ...
|
||||
def __repr__(self) -> str: ...
|
||||
def __str__(self) -> str: ...
|
||||
def _format(self) -> str: ...
|
||||
def _consume_done_getters(self) -> None: ...
|
||||
def _consume_done_putters(self) -> None: ...
|
||||
def qsize(self) -> int: ...
|
||||
@property
|
||||
def maxsize(self) -> int: ...
|
||||
def empty(self) -> bool: ...
|
||||
def full(self) -> bool: ...
|
||||
@coroutine
|
||||
def put(self, item: _T) -> Generator[Any, None, None]: ...
|
||||
def put_nowait(self, item: _T) -> None: ...
|
||||
@coroutine
|
||||
def get(self) -> Generator[Any, None, _T]: ...
|
||||
def get_nowait(self) -> _T: ...
|
||||
@coroutine
|
||||
def join(self) -> Generator[Any, None, bool]: ...
|
||||
def task_done(self) -> None: ...
|
||||
|
||||
|
||||
class PriorityQueue(Queue[_T]): ...
|
||||
|
||||
|
||||
class LifoQueue(Queue[_T]): ...
|
||||
|
||||
if sys.version_info < (3, 5):
|
||||
class JoinableQueue(Queue[_T]):
|
||||
def task_done(self) -> None: ...
|
||||
@coroutine
|
||||
def join(self) -> Generator[Any, None, bool]: ...
|
||||
109
stdlib/3/asyncio/streams.pyi
Normal file
109
stdlib/3/asyncio/streams.pyi
Normal file
@@ -0,0 +1,109 @@
|
||||
import sys
|
||||
from typing import Any, Awaitable, Callable, Generator, Iterable, List, Optional, Tuple, Union
|
||||
|
||||
from . import coroutines
|
||||
from . import events
|
||||
from . import protocols
|
||||
from . import transports
|
||||
|
||||
_ClientConnectedCallback = Callable[[StreamReader, StreamWriter], Optional[Awaitable[None]]]
|
||||
|
||||
|
||||
__all__: List[str]
|
||||
|
||||
class IncompleteReadError(EOFError):
|
||||
expected = ... # type: Optional[int]
|
||||
partial = ... # type: bytes
|
||||
def __init__(self, partial: bytes, expected: Optional[int]) -> None: ...
|
||||
|
||||
class LimitOverrunError(Exception):
|
||||
consumed = ... # type: int
|
||||
def __init__(self, message: str, consumed: int) -> None: ...
|
||||
|
||||
@coroutines.coroutine
|
||||
def open_connection(
|
||||
host: str = ...,
|
||||
port: Union[int, str] = ...,
|
||||
*,
|
||||
loop: Optional[events.AbstractEventLoop] = ...,
|
||||
limit: int = ...,
|
||||
**kwds: Any
|
||||
) -> Generator[Any, None, Tuple[StreamReader, StreamWriter]]: ...
|
||||
|
||||
@coroutines.coroutine
|
||||
def start_server(
|
||||
client_connected_cb: _ClientConnectedCallback,
|
||||
host: Optional[str] = ...,
|
||||
port: Optional[Union[int, str]] = ...,
|
||||
*,
|
||||
loop: Optional[events.AbstractEventLoop] = ...,
|
||||
limit: int = ...,
|
||||
**kwds: Any
|
||||
) -> Generator[Any, None, events.AbstractServer]: ...
|
||||
|
||||
if sys.platform != 'win32':
|
||||
@coroutines.coroutine
|
||||
def open_unix_connection(
|
||||
path: str = ...,
|
||||
*,
|
||||
loop: Optional[events.AbstractEventLoop] = ...,
|
||||
limit: int = ...,
|
||||
**kwds: Any
|
||||
) -> Generator[Any, None, Tuple[StreamReader, StreamWriter]]: ...
|
||||
|
||||
@coroutines.coroutine
|
||||
def start_unix_server(
|
||||
client_connected_cb: _ClientConnectedCallback,
|
||||
path: str = ...,
|
||||
*,
|
||||
loop: Optional[events.AbstractEventLoop] = ...,
|
||||
limit: int = ...,
|
||||
**kwds: Any) -> Generator[Any, None, events.AbstractServer]: ...
|
||||
|
||||
class FlowControlMixin(protocols.Protocol): ...
|
||||
|
||||
class StreamReaderProtocol(FlowControlMixin, protocols.Protocol):
|
||||
def __init__(self,
|
||||
stream_reader: StreamReader,
|
||||
client_connected_cb: _ClientConnectedCallback = ...,
|
||||
loop: Optional[events.AbstractEventLoop] = ...) -> None: ...
|
||||
def connection_made(self, transport: transports.BaseTransport) -> None: ...
|
||||
def connection_lost(self, exc: Exception) -> None: ...
|
||||
def data_received(self, data: bytes) -> None: ...
|
||||
def eof_received(self) -> bool: ...
|
||||
|
||||
class StreamWriter:
|
||||
def __init__(self,
|
||||
transport: transports.BaseTransport,
|
||||
protocol: protocols.BaseProtocol,
|
||||
reader: StreamReader,
|
||||
loop: events.AbstractEventLoop) -> None: ...
|
||||
@property
|
||||
def transport(self) -> transports.BaseTransport: ...
|
||||
def write(self, data: bytes) -> None: ...
|
||||
def writelines(self, data: Iterable[bytes]) -> None: ...
|
||||
def write_eof(self) -> None: ...
|
||||
def can_write_eof(self) -> bool: ...
|
||||
def close(self) -> None: ...
|
||||
def get_extra_info(self, name: str, default: Any = ...) -> Any: ...
|
||||
@coroutines.coroutine
|
||||
def drain(self) -> Generator[Any, None, None]: ...
|
||||
|
||||
class StreamReader:
|
||||
def __init__(self,
|
||||
limit: int = ...,
|
||||
loop: Optional[events.AbstractEventLoop] = ...) -> None: ...
|
||||
def exception(self) -> Exception: ...
|
||||
def set_exception(self, exc: Exception) -> None: ...
|
||||
def set_transport(self, transport: transports.BaseTransport) -> None: ...
|
||||
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]: ...
|
||||
67
stdlib/3/asyncio/subprocess.pyi
Normal file
67
stdlib/3/asyncio/subprocess.pyi
Normal file
@@ -0,0 +1,67 @@
|
||||
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, List, Optional, Text, Tuple, Union, IO
|
||||
|
||||
__all__: List[str]
|
||||
|
||||
PIPE = ... # type: int
|
||||
STDOUT = ... # type: int
|
||||
DEVNULL = ... # type: int
|
||||
|
||||
class SubprocessStreamProtocol(streams.FlowControlMixin,
|
||||
protocols.SubprocessProtocol):
|
||||
stdin = ... # type: Optional[streams.StreamWriter]
|
||||
stdout = ... # type: Optional[streams.StreamReader]
|
||||
stderr = ... # type: Optional[streams.StreamReader]
|
||||
def __init__(self, limit: int, loop: events.AbstractEventLoop) -> None: ...
|
||||
def connection_made(self, transport: transports.BaseTransport) -> None: ...
|
||||
def pipe_data_received(self, fd: int, data: Union[bytes, Text]) -> None: ...
|
||||
def pipe_connection_lost(self, fd: int, exc: Exception) -> None: ...
|
||||
def process_exited(self) -> None: ...
|
||||
|
||||
|
||||
class Process:
|
||||
stdin = ... # type: Optional[streams.StreamWriter]
|
||||
stdout = ... # type: Optional[streams.StreamReader]
|
||||
stderr = ... # type: Optional[streams.StreamReader]
|
||||
pid = ... # type: int
|
||||
def __init__(self,
|
||||
transport: transports.BaseTransport,
|
||||
protocol: protocols.BaseProtocol,
|
||||
loop: events.AbstractEventLoop) -> None: ...
|
||||
@property
|
||||
def returncode(self) -> int: ...
|
||||
@coroutine
|
||||
def wait(self) -> Generator[Any, None, 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]]: ...
|
||||
|
||||
|
||||
@coroutine
|
||||
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] = ...,
|
||||
stderr: Union[int, IO[Any], None] = ...,
|
||||
loop: events.AbstractEventLoop = ...,
|
||||
limit: int = ...,
|
||||
**kwds: Any
|
||||
) -> Generator[Any, None, Process]: ...
|
||||
|
||||
@coroutine
|
||||
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] = ...,
|
||||
stdout: Union[int, IO[Any], None] = ...,
|
||||
stderr: Union[int, IO[Any], None] = ...,
|
||||
loop: events.AbstractEventLoop = ...,
|
||||
limit: int = ...,
|
||||
**kwds: Any
|
||||
) -> Generator[Any, None, Process]: ...
|
||||
72
stdlib/3/asyncio/tasks.pyi
Normal file
72
stdlib/3/asyncio/tasks.pyi
Normal file
@@ -0,0 +1,72 @@
|
||||
from typing import (Any, TypeVar, Set, Dict, List, TextIO, Union, Tuple, Generic, Callable,
|
||||
Coroutine, Generator, Iterable, Awaitable, overload, Sequence, Iterator,
|
||||
Optional)
|
||||
from types import FrameType
|
||||
import concurrent.futures
|
||||
from .events import AbstractEventLoop
|
||||
from .futures import Future
|
||||
|
||||
__all__: List[str]
|
||||
|
||||
_T = TypeVar('_T')
|
||||
_T1 = TypeVar('_T1')
|
||||
_T2 = TypeVar('_T2')
|
||||
_T3 = TypeVar('_T3')
|
||||
_T4 = TypeVar('_T4')
|
||||
_T5 = TypeVar('_T5')
|
||||
_FutureT = Union[Future[_T], Generator[Any, None, _T], Awaitable[_T]]
|
||||
|
||||
FIRST_EXCEPTION: str
|
||||
FIRST_COMPLETED: str
|
||||
ALL_COMPLETED: str
|
||||
|
||||
def as_completed(fs: Sequence[_FutureT[_T]], *, loop: AbstractEventLoop = ...,
|
||||
timeout: Optional[float] = ...) -> Iterator[Generator[Any, None, _T]]: ...
|
||||
def ensure_future(coro_or_future: _FutureT[_T],
|
||||
*, loop: AbstractEventLoop = ...) -> Future[_T]: ...
|
||||
# Prior to Python 3.7 'async' was an alias for 'ensure_future'.
|
||||
# It became a keyword in 3.7.
|
||||
@overload
|
||||
def gather(coro_or_future1: _FutureT[_T1],
|
||||
*, loop: AbstractEventLoop = ..., return_exceptions: bool = ...) -> Future[Tuple[_T1]]: ...
|
||||
@overload
|
||||
def gather(coro_or_future1: _FutureT[_T1], coro_or_future2: _FutureT[_T2],
|
||||
*, loop: AbstractEventLoop = ..., return_exceptions: bool = ...) -> Future[Tuple[_T1, _T2]]: ...
|
||||
@overload
|
||||
def gather(coro_or_future1: _FutureT[_T1], coro_or_future2: _FutureT[_T2], coro_or_future3: _FutureT[_T3],
|
||||
*, loop: AbstractEventLoop = ..., return_exceptions: bool = ...) -> Future[Tuple[_T1, _T2, _T3]]: ...
|
||||
@overload
|
||||
def gather(coro_or_future1: _FutureT[_T1], coro_or_future2: _FutureT[_T2], coro_or_future3: _FutureT[_T3],
|
||||
coro_or_future4: _FutureT[_T4],
|
||||
*, loop: AbstractEventLoop = ..., return_exceptions: bool = ...) -> Future[Tuple[_T1, _T2, _T3, _T4]]: ...
|
||||
@overload
|
||||
def gather(coro_or_future1: _FutureT[_T1], coro_or_future2: _FutureT[_T2], coro_or_future3: _FutureT[_T3],
|
||||
coro_or_future4: _FutureT[_T4], coro_or_future5: _FutureT[_T5],
|
||||
*, loop: AbstractEventLoop = ..., return_exceptions: bool = ...) -> Future[Tuple[_T1, _T2, _T3, _T4, _T5]]: ...
|
||||
@overload
|
||||
def gather(coro_or_future1: _FutureT[Any], coro_or_future2: _FutureT[Any], coro_or_future3: _FutureT[Any],
|
||||
coro_or_future4: _FutureT[Any], coro_or_future5: _FutureT[Any], coro_or_future6: _FutureT[Any],
|
||||
*coros_or_futures: _FutureT[Any],
|
||||
loop: AbstractEventLoop = ..., return_exceptions: bool = ...) -> Future[Tuple[Any, ...]]: ...
|
||||
def run_coroutine_threadsafe(coro: _FutureT[_T],
|
||||
loop: AbstractEventLoop) -> concurrent.futures.Future[_T]: ...
|
||||
def shield(arg: _FutureT[_T], *, loop: AbstractEventLoop = ...) -> Future[_T]: ...
|
||||
def sleep(delay: float, result: _T = ..., loop: AbstractEventLoop = ...) -> Future[_T]: ...
|
||||
def wait(fs: Iterable[_FutureT[_T]], *, loop: AbstractEventLoop = ...,
|
||||
timeout: Optional[float] = ...,
|
||||
return_when: str = ...) -> Future[Tuple[Set[Future[_T]], Set[Future[_T]]]]: ...
|
||||
def wait_for(fut: _FutureT[_T], timeout: Optional[float],
|
||||
*, loop: AbstractEventLoop = ...) -> Future[_T]: ...
|
||||
|
||||
class Task(Future[_T], Generic[_T]):
|
||||
@classmethod
|
||||
def current_task(cls, loop: AbstractEventLoop = ...) -> Task: ...
|
||||
@classmethod
|
||||
def all_tasks(cls, loop: AbstractEventLoop = ...) -> Set[Task]: ...
|
||||
def __init__(self, coro: Union[Generator[Any, None, _T], Awaitable[_T]], *, loop: AbstractEventLoop = ...) -> None: ...
|
||||
def __repr__(self) -> str: ...
|
||||
def get_stack(self, *, limit: int = ...) -> List[FrameType]: ...
|
||||
def print_stack(self, *, limit: int = ..., file: TextIO = ...) -> None: ...
|
||||
def cancel(self) -> bool: ...
|
||||
def _step(self, value: Any = ..., exc: Exception = ...) -> None: ...
|
||||
def _wakeup(self, future: Future[Any]) -> None: ...
|
||||
38
stdlib/3/asyncio/transports.pyi
Normal file
38
stdlib/3/asyncio/transports.pyi
Normal file
@@ -0,0 +1,38 @@
|
||||
from typing import Dict, Any, TypeVar, Mapping, List, Optional, Tuple
|
||||
|
||||
__all__: List[str]
|
||||
|
||||
class BaseTransport:
|
||||
def __init__(self, extra: Mapping[Any, Any] = ...) -> None: ...
|
||||
def get_extra_info(self, name: Any, default: Any = ...) -> Any: ...
|
||||
def is_closing(self) -> bool: ...
|
||||
def close(self) -> None: ...
|
||||
|
||||
class ReadTransport(BaseTransport):
|
||||
def pause_reading(self) -> None: ...
|
||||
def resume_reading(self) -> None: ...
|
||||
|
||||
class WriteTransport(BaseTransport):
|
||||
def set_write_buffer_limits(
|
||||
self, high: int = ..., low: int = ...
|
||||
) -> None: ...
|
||||
def get_write_buffer_size(self) -> int: ...
|
||||
def write(self, data: Any) -> None: ...
|
||||
def writelines(self, list_of_data: List[Any]) -> None: ...
|
||||
def write_eof(self) -> None: ...
|
||||
def can_write_eof(self) -> bool: ...
|
||||
def abort(self) -> None: ...
|
||||
|
||||
class Transport(ReadTransport, WriteTransport): ...
|
||||
|
||||
class DatagramTransport(BaseTransport):
|
||||
def sendto(self, data: Any, addr: Optional[Tuple[str, int]] = ...) -> None: ...
|
||||
def abort(self) -> None: ...
|
||||
|
||||
class SubprocessTransport(BaseTransport):
|
||||
def get_pid(self) -> int: ...
|
||||
def get_returncode(self) -> int: ...
|
||||
def get_pipe_transport(self, fd: int) -> BaseTransport: ...
|
||||
def send_signal(self, signal: int) -> int: ...
|
||||
def terminate(self) -> None: ...
|
||||
def kill(self) -> None: ...
|
||||
Reference in New Issue
Block a user