@@ -422,6 +422,9 @@ cdef class Loop:
422422 " Non-thread-safe operation invoked on an event loop other "
423423 " than the current one" )
424424
425+ cdef inline _new_future(self ):
426+ return aio_Future(loop = self )
427+
425428 cdef inline _add_reader(self , fd, Handle handle):
426429 cdef:
427430 UVPoll poll
@@ -489,7 +492,7 @@ cdef class Loop:
489492 int proto, int flags,
490493 int unpack):
491494
492- fut = aio_Future( loop = self )
495+ fut = self ._new_future( )
493496
494497 def callback (result ):
495498 if AddrInfo.isinstance(result):
@@ -512,7 +515,7 @@ cdef class Loop:
512515
513516 cdef _getnameinfo(self , system.sockaddr * addr, int flags):
514517 cdef NameInfoRequest nr
515- fut = aio_Future( loop = self )
518+ fut = self ._new_future( )
516519
517520 def callback (result ):
518521 if isinstance (result, tuple ):
@@ -1054,7 +1057,7 @@ cdef class Loop:
10541057 ' when using ssl without a host' )
10551058 server_hostname = host
10561059
1057- ssl_waiter = aio_Future( loop = self )
1060+ ssl_waiter = self ._new_future( )
10581061 sslcontext = None if isinstance (ssl, bool ) else ssl
10591062 protocol = aio_SSLProtocol(
10601063 self , app_protocol, sslcontext, ssl_waiter,
@@ -1099,7 +1102,7 @@ cdef class Loop:
10991102 while rai is not NULL :
11001103 tr = None
11011104 try :
1102- waiter = aio_Future( loop = self )
1105+ waiter = self ._new_future( )
11031106 tr = UVTCPTransport.new(self , protocol, None , waiter)
11041107 if ai_local is not None :
11051108 lai = ai_local.data
@@ -1149,7 +1152,7 @@ cdef class Loop:
11491152 raise ValueError (
11501153 ' host and port was not specified and no sock specified' )
11511154
1152- waiter = aio_Future( loop = self )
1155+ waiter = self ._new_future( )
11531156 protocol = protocol_factory()
11541157 tr = UVTCPTransport.new(self , protocol, None , waiter)
11551158 try :
@@ -1238,7 +1241,7 @@ cdef class Loop:
12381241 raise ValueError (' You must set server_hostname '
12391242 ' when using ssl without a host' )
12401243
1241- ssl_waiter = aio_Future( loop = self )
1244+ ssl_waiter = self ._new_future( )
12421245 sslcontext = None if isinstance (ssl, bool ) else ssl
12431246 protocol = aio_SSLProtocol(
12441247 self , app_protocol, sslcontext, ssl_waiter,
@@ -1255,7 +1258,7 @@ cdef class Loop:
12551258 raise ValueError (
12561259 ' path and sock can not be specified at the same time' )
12571260
1258- waiter = aio_Future( loop = self )
1261+ waiter = self ._new_future( )
12591262 tr = UVPipeTransport.new(self , protocol, None , waiter)
12601263 tr.connect(path)
12611264 try :
@@ -1272,7 +1275,7 @@ cdef class Loop:
12721275 raise ValueError (
12731276 ' A UNIX Domain Socket was expected, got {!r}' .format(sock))
12741277
1275- waiter = aio_Future( loop = self )
1278+ waiter = self ._new_future( )
12761279 tr = UVPipeTransport.new(self , protocol, None , waiter)
12771280 try :
12781281 # libuv will make socket non-blocking
@@ -1370,14 +1373,14 @@ cdef class Loop:
13701373 def sock_recv (self , sock , n ):
13711374 if self ._debug and sock.gettimeout() != 0 :
13721375 raise ValueError (" the socket must be non-blocking" )
1373- fut = aio_Future( loop = self )
1376+ fut = self ._new_future( )
13741377 self ._sock_recv(fut, 0 , sock, n)
13751378 return fut
13761379
13771380 def sock_sendall (self , sock , data ):
13781381 if self ._debug and sock.gettimeout() != 0 :
13791382 raise ValueError (" the socket must be non-blocking" )
1380- fut = aio_Future( loop = self )
1383+ fut = self ._new_future( )
13811384 if data:
13821385 self ._sock_sendall(fut, 0 , sock, data)
13831386 else :
@@ -1387,14 +1390,14 @@ cdef class Loop:
13871390 def sock_accept (self , sock ):
13881391 if self ._debug and sock.gettimeout() != 0 :
13891392 raise ValueError (" the socket must be non-blocking" )
1390- fut = aio_Future( loop = self )
1393+ fut = self ._new_future( )
13911394 self ._sock_accept(fut, 0 , sock)
13921395 return fut
13931396
13941397 def sock_connect (self , sock , address ):
13951398 if self ._debug and sock.gettimeout() != 0 :
13961399 raise ValueError (" the socket must be non-blocking" )
1397- fut = aio_Future( loop = self )
1400+ fut = self ._new_future( )
13981401 try :
13991402 if self ._debug:
14001403 aio__check_resolved_address(sock, address)
@@ -1462,7 +1465,7 @@ cdef class Loop:
14621465 if executable is not None :
14631466 args[0 ] = executable
14641467
1465- waiter = aio_Future( loop = self )
1468+ waiter = self ._new_future( )
14661469 protocol = protocol_factory()
14671470 proc = UVProcessTransport.new(self , protocol,
14681471 args, env, cwd, start_new_session,
@@ -1507,7 +1510,7 @@ cdef class Loop:
15071510 UVReadPipeTransport transp
15081511 int fileno = os_dup(pipe.fileno())
15091512
1510- waiter = aio_Future( loop = self )
1513+ waiter = self ._new_future( )
15111514 proto = proto_factory()
15121515 transp = UVReadPipeTransport.new(self , proto, None , waiter)
15131516 transp._add_extra_info(' pipe' , pipe)
@@ -1527,7 +1530,7 @@ cdef class Loop:
15271530 UVWritePipeTransport transp
15281531 int fileno = os_dup(pipe.fileno())
15291532
1530- waiter = aio_Future( loop = self )
1533+ waiter = self ._new_future( )
15311534 proto = proto_factory()
15321535 transp = UVWritePipeTransport.new(self , proto, None , waiter)
15331536 transp._add_extra_info(' pipe' , pipe)
0 commit comments