mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-22 20:01:29 +08:00
Improve asyncio APIs which take TCP port (#2006)
They have getaddrinfo(3) as their backend, and accept port='http' etc. You can even omit (pass None to) either of host or port for start_server() to effectively select 'localhost' and an arbitrary ephemeral port, respectively.
This commit is contained in:
committed by
Jelle Zijlstra
parent
a994c47198
commit
b472130201
@@ -1,5 +1,5 @@
|
||||
import sys
|
||||
from typing import Any, Awaitable, Callable, Generator, Iterable, List, Optional, Tuple
|
||||
from typing import Any, Awaitable, Callable, Generator, Iterable, List, Optional, Tuple, Union
|
||||
|
||||
from . import coroutines
|
||||
from . import events
|
||||
@@ -23,7 +23,7 @@ class LimitOverrunError(Exception):
|
||||
@coroutines.coroutine
|
||||
def open_connection(
|
||||
host: str = ...,
|
||||
port: int = ...,
|
||||
port: Union[int, str] = ...,
|
||||
*,
|
||||
loop: Optional[events.AbstractEventLoop] = ...,
|
||||
limit: int = ...,
|
||||
@@ -33,8 +33,8 @@ def open_connection(
|
||||
@coroutines.coroutine
|
||||
def start_server(
|
||||
client_connected_cb: _ClientConnectedCallback,
|
||||
host: str = ...,
|
||||
port: int = ...,
|
||||
host: Optional[str] = ...,
|
||||
port: Optional[Union[int, str]] = ...,
|
||||
*,
|
||||
loop: Optional[events.AbstractEventLoop] = ...,
|
||||
limit: int = ...,
|
||||
|
||||
Reference in New Issue
Block a user