@@ -11,6 +11,9 @@ from asyncio.protocols import BaseProtocol
11
11
from asyncio .tasks import Task
12
12
from asyncio .transports import BaseTransport
13
13
14
+ if sys .version_info >= (3 , 7 ):
15
+ from contextvars import Context
16
+
14
17
_T = TypeVar ('_T' )
15
18
_Context = Dict [str , Any ]
16
19
_ExceptionHandler = Callable [[AbstractEventLoop , _Context ], Any ]
@@ -37,9 +40,18 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta):
37
40
@coroutine
38
41
def shutdown_asyncgens (self ) -> Generator [Any , None , None ]: ...
39
42
# Methods scheduling callbacks. All these return Handles.
40
- def call_soon (self , callback : Callable [..., Any ], * args : Any ) -> Handle : ...
41
- def call_later (self , delay : float , callback : Callable [..., Any ], * args : Any ) -> TimerHandle : ...
42
- def call_at (self , when : float , callback : Callable [..., Any ], * args : Any ) -> TimerHandle : ...
43
+ if sys .version_info >= (3 , 7 ):
44
+ def call_soon (self , callback : Callable [..., Any ], * args : Any , context : Optional [Context ] = ...) -> Handle : ...
45
+ def call_later (
46
+ self , delay : float , callback : Callable [..., Any ], * args : Any , context : Optional [Context ] = ...,
47
+ ) -> TimerHandle : ...
48
+ def call_at (
49
+ self , when : float , callback : Callable [..., Any ], * args : Any , context : Optional [Context ] = ...,
50
+ ) -> TimerHandle : ...
51
+ else :
52
+ def call_soon (self , callback : Callable [..., Any ], * args : Any ) -> Handle : ...
53
+ def call_later (self , delay : float , callback : Callable [..., Any ], * args : Any ) -> TimerHandle : ...
54
+ def call_at (self , when : float , callback : Callable [..., Any ], * args : Any ) -> TimerHandle : ...
43
55
def time (self ) -> float : ...
44
56
# Future methods
45
57
def create_future (self ) -> Future [Any ]: ...
@@ -53,7 +65,10 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta):
53
65
def set_task_factory (self , factory : Optional [Callable [[AbstractEventLoop , Generator [Any , None , _T ]], Future [_T ]]]) -> None : ...
54
66
def get_task_factory (self ) -> Optional [Callable [[AbstractEventLoop , Generator [Any , None , _T ]], Future [_T ]]]: ...
55
67
# Methods for interacting with threads
56
- def call_soon_threadsafe (self , callback : Callable [..., Any ], * args : Any ) -> Handle : ...
68
+ if sys .version_info >= (3 , 7 ):
69
+ def call_soon_threadsafe (self , callback : Callable [..., Any ], * args : Any , context : Optional [Context ] = ...) -> Handle : ...
70
+ else :
71
+ def call_soon_threadsafe (self , callback : Callable [..., Any ], * args : Any ) -> Handle : ...
57
72
@coroutine
58
73
def run_in_executor (self , executor : Any ,
59
74
func : Callable [..., _T ], * args : Any ) -> Generator [Any , None , _T ]: ...
@@ -67,9 +82,44 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta):
67
82
flags : int = ...) -> Generator [Any , None , List [Tuple [int , int , int , str , Tuple [Any , ...]]]]: ...
68
83
@coroutine
69
84
def getnameinfo (self , sockaddr : Tuple [Any , ...], flags : int = ...) -> Generator [Any , None , Tuple [str , int ]]: ...
70
- if sys .version_info >= (3 , 7 ):
71
- async def sock_sendfile (self , sock : socket , file : IO [bytes ], offset : int = ..., count : Optional [int ] = ..., * ,
72
- fallback : bool = ...) -> int : ...
85
+ if sys .version_info >= (3 , 8 ):
86
+ @overload
87
+ async def create_connection (
88
+ self ,
89
+ protocol_factory : _ProtocolFactory ,
90
+ host : str = ...,
91
+ port : int = ...,
92
+ * ,
93
+ ssl : _SSLContext = ...,
94
+ family : int = ...,
95
+ proto : int = ...,
96
+ flags : int = ...,
97
+ sock : None = ...,
98
+ local_addr : Optional [str ] = ...,
99
+ server_hostname : Optional [str ] = ...,
100
+ ssl_handshake_timeout : Optional [float ] = ...,
101
+ happy_eyeballs_delay : Optional [float ] = ...,
102
+ interleave : Optional [int ] = ...,
103
+ ) -> _TransProtPair : ...
104
+ @overload
105
+ async def create_connection (
106
+ self ,
107
+ protocol_factory : _ProtocolFactory ,
108
+ host : None = ...,
109
+ port : None = ...,
110
+ * ,
111
+ ssl : _SSLContext = ...,
112
+ family : int = ...,
113
+ proto : int = ...,
114
+ flags : int = ...,
115
+ sock : socket ,
116
+ local_addr : None = ...,
117
+ server_hostname : Optional [str ] = ...,
118
+ ssl_handshake_timeout : Optional [float ] = ...,
119
+ happy_eyeballs_delay : Optional [float ] = ...,
120
+ interleave : Optional [int ] = ...,
121
+ ) -> _TransProtPair : ...
122
+ elif sys .version_info >= (3 , 7 ):
73
123
@overload
74
124
async def create_connection (self , protocol_factory : _ProtocolFactory , host : str = ..., port : int = ..., * ,
75
125
ssl : _SSLContext = ..., family : int = ..., proto : int = ..., flags : int = ...,
@@ -80,6 +130,20 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta):
80
130
ssl : _SSLContext = ..., family : int = ..., proto : int = ..., flags : int = ...,
81
131
sock : socket , local_addr : None = ..., server_hostname : Optional [str ] = ...,
82
132
ssl_handshake_timeout : Optional [float ] = ...) -> _TransProtPair : ...
133
+ else :
134
+ @overload
135
+ @coroutine
136
+ def create_connection (self , protocol_factory : _ProtocolFactory , host : str = ..., port : int = ..., * ,
137
+ ssl : _SSLContext = ..., family : int = ..., proto : int = ..., flags : int = ..., sock : None = ...,
138
+ local_addr : Optional [str ] = ..., server_hostname : Optional [str ] = ...) -> Generator [Any , None , _TransProtPair ]: ...
139
+ @overload
140
+ @coroutine
141
+ def create_connection (self , protocol_factory : _ProtocolFactory , host : None = ..., port : None = ..., * ,
142
+ ssl : _SSLContext = ..., family : int = ..., proto : int = ..., flags : int = ..., sock : socket ,
143
+ local_addr : None = ..., server_hostname : Optional [str ] = ...) -> Generator [Any , None , _TransProtPair ]: ...
144
+ if sys .version_info >= (3 , 7 ):
145
+ async def sock_sendfile (self , sock : socket , file : IO [bytes ], offset : int = ..., count : Optional [int ] = ..., * ,
146
+ fallback : bool = ...) -> int : ...
83
147
@overload
84
148
async def create_server (self , protocol_factory : _ProtocolFactory , host : Optional [Union [str , Sequence [str ]]] = ...,
85
149
port : int = ..., * , family : int = ..., flags : int = ..., sock : None = ..., backlog : int = ...,
@@ -100,16 +164,6 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta):
100
164
else :
101
165
@overload
102
166
@coroutine
103
- def create_connection (self , protocol_factory : _ProtocolFactory , host : str = ..., port : int = ..., * ,
104
- ssl : _SSLContext = ..., family : int = ..., proto : int = ..., flags : int = ..., sock : None = ...,
105
- local_addr : Optional [str ] = ..., server_hostname : Optional [str ] = ...) -> Generator [Any , None , _TransProtPair ]: ...
106
- @overload
107
- @coroutine
108
- def create_connection (self , protocol_factory : _ProtocolFactory , host : None = ..., port : None = ..., * ,
109
- ssl : _SSLContext = ..., family : int = ..., proto : int = ..., flags : int = ..., sock : socket ,
110
- local_addr : None = ..., server_hostname : Optional [str ] = ...) -> Generator [Any , None , _TransProtPair ]: ...
111
- @overload
112
- @coroutine
113
167
def create_server (self , protocol_factory : _ProtocolFactory , host : Optional [Union [str , Sequence [str ]]] = ..., port : int = ..., * ,
114
168
family : int = ..., flags : int = ...,
115
169
sock : None = ..., backlog : int = ..., ssl : _SSLContext = ...,
0 commit comments