1
1
import selectors
2
- from socket import socket , _Address
2
+ from socket import socket , _Address , _RetAddress
3
3
import ssl
4
4
import sys
5
- from typing import Any , Awaitable , Callable , Dict , Generator , List , Optional , Sequence , Tuple , TypeVar , Union , overload
5
+ from typing import Any , Awaitable , Callable , Dict , Generator , IO , List , Optional , Sequence , Tuple , TypeVar , Union , overload
6
6
from asyncio .futures import Future
7
7
from asyncio .coroutines import coroutine
8
8
from asyncio .events import AbstractEventLoop , AbstractServer , Handle , TimerHandle
@@ -59,46 +59,83 @@ class BaseEventLoop(AbstractEventLoop):
59
59
flags : int = ...) -> Generator [Any , None , List [Tuple [int , int , int , str , Tuple [Any , ...]]]]: ...
60
60
@coroutine
61
61
def getnameinfo (self , sockaddr : tuple , flags : int = ...) -> Generator [Any , None , Tuple [str , int ]]: ...
62
- @overload
63
- @coroutine
64
- def create_connection (self , protocol_factory : _ProtocolFactory , host : str = ..., port : int = ..., * ,
65
- ssl : _SSLContext = ..., family : int = ..., proto : int = ..., flags : int = ..., sock : None = ...,
66
- local_addr : Optional [str ] = ..., server_hostname : Optional [str ] = ...) -> Generator [Any , None , _TransProtPair ]: ...
67
- @overload
68
- @coroutine
69
- def create_connection (self , protocol_factory : _ProtocolFactory , host : None = ..., port : None = ..., * ,
70
- ssl : _SSLContext = ..., family : int = ..., proto : int = ..., flags : int = ..., sock : socket ,
71
- local_addr : None = ..., server_hostname : Optional [str ] = ...) -> Generator [Any , None , _TransProtPair ]: ...
72
- @overload
73
- @coroutine
74
- def create_server (self , protocol_factory : _ProtocolFactory , host : Optional [Union [str , Sequence [str ]]] = ..., port : int = ..., * ,
75
- family : int = ..., flags : int = ...,
76
- sock : None = ..., backlog : int = ..., ssl : _SSLContext = ...,
77
- reuse_address : Optional [bool ] = ...,
78
- reuse_port : Optional [bool ] = ...) -> Generator [Any , None , AbstractServer ]: ...
79
- @overload
80
- @coroutine
81
- def create_server (self , protocol_factory : _ProtocolFactory , host : None = ..., port : None = ..., * ,
82
- family : int = ..., flags : int = ...,
83
- sock : socket , backlog : int = ..., ssl : _SSLContext = ...,
84
- reuse_address : Optional [bool ] = ...,
85
- reuse_port : Optional [bool ] = ...) -> Generator [Any , None , AbstractServer ]: ...
86
- @coroutine
87
- def create_unix_connection (self , protocol_factory : _ProtocolFactory , path : str , * ,
88
- ssl : _SSLContext = ..., sock : Optional [socket ] = ...,
89
- server_hostname : str = ...) -> Generator [Any , None , _TransProtPair ]: ...
90
- @coroutine
91
- def create_unix_server (self , protocol_factory : _ProtocolFactory , path : str , * ,
92
- sock : Optional [socket ] = ..., backlog : int = ..., ssl : _SSLContext = ...) -> Generator [Any , None , AbstractServer ]: ...
62
+ if sys .version_info >= (3 , 7 ):
63
+ async def sock_sendfile (self , sock : socket , file : IO [bytes ], offset : int = ..., count : Optional [int ] = ..., * ,
64
+ fallback : bool = ...) -> int : ...
65
+ @overload
66
+ async def create_connection (self , protocol_factory : _ProtocolFactory , host : str = ..., port : int = ..., * ,
67
+ ssl : _SSLContext = ..., family : int = ..., proto : int = ..., flags : int = ...,
68
+ sock : None = ..., local_addr : Optional [str ] = ..., server_hostname : Optional [str ] = ...,
69
+ ssl_handshake_timeout : Optional [float ] = ...) -> _TransProtPair : ...
70
+ @overload
71
+ async def create_connection (self , protocol_factory : _ProtocolFactory , host : None = ..., port : None = ..., * ,
72
+ ssl : _SSLContext = ..., family : int = ..., proto : int = ..., flags : int = ...,
73
+ sock : socket , local_addr : None = ..., server_hostname : Optional [str ] = ...,
74
+ ssl_handshake_timeout : Optional [float ] = ...) -> _TransProtPair : ...
75
+ @overload
76
+ async def create_server (self , protocol_factory : _ProtocolFactory , host : Optional [Union [str , Sequence [str ]]] = ...,
77
+ port : int = ..., * , family : int = ..., flags : int = ..., sock : None = ..., backlog : int = ...,
78
+ ssl : _SSLContext = ..., reuse_address : Optional [bool ] = ..., reuse_port : Optional [bool ] = ...,
79
+ ssl_handshake_timeout : Optional [float ] = ..., start_serving : bool = ...) -> AbstractServer : ...
80
+ @overload
81
+ async def create_server (self , protocol_factory : _ProtocolFactory , host : None = ..., port : None = ..., * ,
82
+ family : int = ..., flags : int = ..., sock : socket = ..., backlog : int = ...,
83
+ ssl : _SSLContext = ..., reuse_address : Optional [bool ] = ..., reuse_port : Optional [bool ] = ...,
84
+ ssl_handshake_timeout : Optional [float ] = ..., start_serving : bool = ...) -> AbstractServer : ...
85
+ async def create_unix_connection (self , protocol_factory : _ProtocolFactory , path : str , * , ssl : _SSLContext = ...,
86
+ sock : Optional [socket ] = ..., server_hostname : str = ...,
87
+ ssl_handshake_timeout : Optional [float ]) -> _TransProtPair : ...
88
+ async def create_unix_server (self , protocol_factory : _ProtocolFactory , path : str , * , sock : Optional [socket ] = ...,
89
+ backlog : int = ..., ssl : _SSLContext = ..., ssl_handshake_timeout : Optional [float ] = ...,
90
+ start_serving : bool = ...) -> AbstractServer : ...
91
+ async def connect_accepted_socket (self , protocol_factory : _ProtocolFactory , sock : socket , * , ssl : _SSLContext = ...,
92
+ ssl_handshake_timeout : Optional [float ] = ...) -> _TransProtPair : ...
93
+ async def sendfile (self , transport : BaseTransport , file : IO [bytes ], offset : int = ..., count : Optional [int ] = ..., * ,
94
+ fallback : bool = ...) -> int : ...
95
+ async def start_tls (self , transport : BaseTransport , protocol : BaseProtocol , sslcontext : ssl .SSLContext , * ,
96
+ server_side : bool = ..., server_hostname : Optional [str ] = ...,
97
+ ssl_handshake_timeout : Optional [float ] = ...) -> BaseTransport : ...
98
+ else :
99
+ @overload
100
+ @coroutine
101
+ def create_connection (self , protocol_factory : _ProtocolFactory , host : str = ..., port : int = ..., * ,
102
+ ssl : _SSLContext = ..., family : int = ..., proto : int = ..., flags : int = ..., sock : None = ...,
103
+ local_addr : Optional [str ] = ..., server_hostname : Optional [str ] = ...) -> Generator [Any , None , _TransProtPair ]: ...
104
+ @overload
105
+ @coroutine
106
+ def create_connection (self , protocol_factory : _ProtocolFactory , host : None = ..., port : None = ..., * ,
107
+ ssl : _SSLContext = ..., family : int = ..., proto : int = ..., flags : int = ..., sock : socket ,
108
+ local_addr : None = ..., server_hostname : Optional [str ] = ...) -> Generator [Any , None , _TransProtPair ]: ...
109
+ @overload
110
+ @coroutine
111
+ def create_server (self , protocol_factory : _ProtocolFactory , host : Optional [Union [str , Sequence [str ]]] = ..., port : int = ..., * ,
112
+ family : int = ..., flags : int = ...,
113
+ sock : None = ..., backlog : int = ..., ssl : _SSLContext = ...,
114
+ reuse_address : Optional [bool ] = ...,
115
+ reuse_port : Optional [bool ] = ...) -> Generator [Any , None , AbstractServer ]: ...
116
+ @overload
117
+ @coroutine
118
+ def create_server (self , protocol_factory : _ProtocolFactory , host : None = ..., port : None = ..., * ,
119
+ family : int = ..., flags : int = ...,
120
+ sock : socket , backlog : int = ..., ssl : _SSLContext = ...,
121
+ reuse_address : Optional [bool ] = ...,
122
+ reuse_port : Optional [bool ] = ...) -> Generator [Any , None , AbstractServer ]: ...
123
+ @coroutine
124
+ def create_unix_connection (self , protocol_factory : _ProtocolFactory , path : str , * ,
125
+ ssl : _SSLContext = ..., sock : Optional [socket ] = ...,
126
+ server_hostname : str = ...) -> Generator [Any , None , _TransProtPair ]: ...
127
+ @coroutine
128
+ def create_unix_server (self , protocol_factory : _ProtocolFactory , path : str , * ,
129
+ sock : Optional [socket ] = ..., backlog : int = ..., ssl : _SSLContext = ...) -> Generator [Any , None , AbstractServer ]: ...
130
+ @coroutine
131
+ def connect_accepted_socket (self , protocol_factory : _ProtocolFactory , sock : socket , * , ssl : _SSLContext = ...) -> Generator [Any , None , _TransProtPair ]: ...
93
132
@coroutine
94
133
def create_datagram_endpoint (self , protocol_factory : _ProtocolFactory ,
95
134
local_addr : Optional [Tuple [str , int ]] = ..., remote_addr : Optional [Tuple [str , int ]] = ..., * ,
96
135
family : int = ..., proto : int = ..., flags : int = ...,
97
136
reuse_address : Optional [bool ] = ..., reuse_port : Optional [bool ] = ...,
98
137
allow_broadcast : Optional [bool ] = ...,
99
138
sock : Optional [socket ] = ...) -> Generator [Any , None , _TransProtPair ]: ...
100
- @coroutine
101
- def connect_accepted_socket (self , protocol_factory : _ProtocolFactory , sock : socket , * , ssl : _SSLContext = ...) -> Generator [Any , None , _TransProtPair ]: ...
102
139
# Pipes and subprocesses.
103
140
@coroutine
104
141
def connect_read_pipe (self , protocol_factory : _ProtocolFactory , pipe : Any ) -> Generator [Any , None , _TransProtPair ]: ...
@@ -116,15 +153,18 @@ class BaseEventLoop(AbstractEventLoop):
116
153
def remove_reader (self , fd : selectors ._FileObject ) -> None : ...
117
154
def add_writer (self , fd : selectors ._FileObject , callback : Callable [..., Any ], * args : Any ) -> None : ...
118
155
def remove_writer (self , fd : selectors ._FileObject ) -> None : ...
119
- # Completion based I/O methods returning Futures.
120
- @coroutine
121
- def sock_recv (self , sock : socket , nbytes : int ) -> Generator [Any , None , bytes ]: ...
122
- @coroutine
123
- def sock_sendall (self , sock : socket , data : bytes ) -> Generator [Any , None , None ]: ...
124
- @coroutine
125
- def sock_connect (self , sock : socket , address : _Address ) -> Generator [Any , None , None ]: ...
126
- @coroutine
127
- def sock_accept (self , sock : socket ) -> Generator [Any , None , Tuple [socket , Any ]]: ...
156
+ # Completion based I/O methods returning Futures prior to 3.7
157
+ if sys .version_info >= (3 , 7 ):
158
+ async def sock_recv (self , sock : socket , nbytes : int ) -> bytes : ...
159
+ async def sock_recv_into (self , sock : socket , buf : bytearray ) -> int : ...
160
+ async def sock_sendall (self , sock : socket , data : bytes ) -> None : ...
161
+ async def sock_connect (self , sock : socket , address : _Address ) -> None : ...
162
+ async def sock_accept (self , sock : socket ) -> Tuple [socket , _RetAddress ]: ...
163
+ else :
164
+ def sock_recv (self , sock : socket , nbytes : int ) -> Future [bytes ]: ...
165
+ def sock_sendall (self , sock : socket , data : bytes ) -> Future [None ]: ...
166
+ def sock_connect (self , sock : socket , address : _Address ) -> Future [None ]: ...
167
+ def sock_accept (self , sock : socket ) -> Future [Tuple [socket , _RetAddress ]]: ...
128
168
# Signal handling.
129
169
def add_signal_handler (self , sig : int , callback : Callable [..., Any ], * args : Any ) -> None : ...
130
170
def remove_signal_handler (self , sig : int ) -> None : ...
0 commit comments