@@ -422,6 +422,9 @@ cdef class Loop:
422
422
" Non-thread-safe operation invoked on an event loop other "
423
423
" than the current one" )
424
424
425
+ cdef inline _new_future(self ):
426
+ return aio_Future(loop = self )
427
+
425
428
cdef inline _add_reader(self , fd, Handle handle):
426
429
cdef:
427
430
UVPoll poll
@@ -489,7 +492,7 @@ cdef class Loop:
489
492
int proto, int flags,
490
493
int unpack):
491
494
492
- fut = aio_Future( loop = self )
495
+ fut = self ._new_future( )
493
496
494
497
def callback (result ):
495
498
if AddrInfo.isinstance(result):
@@ -512,7 +515,7 @@ cdef class Loop:
512
515
513
516
cdef _getnameinfo(self , system.sockaddr * addr, int flags):
514
517
cdef NameInfoRequest nr
515
- fut = aio_Future( loop = self )
518
+ fut = self ._new_future( )
516
519
517
520
def callback (result ):
518
521
if isinstance (result, tuple ):
@@ -1054,7 +1057,7 @@ cdef class Loop:
1054
1057
' when using ssl without a host' )
1055
1058
server_hostname = host
1056
1059
1057
- ssl_waiter = aio_Future( loop = self )
1060
+ ssl_waiter = self ._new_future( )
1058
1061
sslcontext = None if isinstance (ssl, bool ) else ssl
1059
1062
protocol = aio_SSLProtocol(
1060
1063
self , app_protocol, sslcontext, ssl_waiter,
@@ -1099,7 +1102,7 @@ cdef class Loop:
1099
1102
while rai is not NULL :
1100
1103
tr = None
1101
1104
try :
1102
- waiter = aio_Future( loop = self )
1105
+ waiter = self ._new_future( )
1103
1106
tr = UVTCPTransport.new(self , protocol, None , waiter)
1104
1107
if ai_local is not None :
1105
1108
lai = ai_local.data
@@ -1149,7 +1152,7 @@ cdef class Loop:
1149
1152
raise ValueError (
1150
1153
' host and port was not specified and no sock specified' )
1151
1154
1152
- waiter = aio_Future( loop = self )
1155
+ waiter = self ._new_future( )
1153
1156
protocol = protocol_factory()
1154
1157
tr = UVTCPTransport.new(self , protocol, None , waiter)
1155
1158
try :
@@ -1238,7 +1241,7 @@ cdef class Loop:
1238
1241
raise ValueError (' You must set server_hostname '
1239
1242
' when using ssl without a host' )
1240
1243
1241
- ssl_waiter = aio_Future( loop = self )
1244
+ ssl_waiter = self ._new_future( )
1242
1245
sslcontext = None if isinstance (ssl, bool ) else ssl
1243
1246
protocol = aio_SSLProtocol(
1244
1247
self , app_protocol, sslcontext, ssl_waiter,
@@ -1255,7 +1258,7 @@ cdef class Loop:
1255
1258
raise ValueError (
1256
1259
' path and sock can not be specified at the same time' )
1257
1260
1258
- waiter = aio_Future( loop = self )
1261
+ waiter = self ._new_future( )
1259
1262
tr = UVPipeTransport.new(self , protocol, None , waiter)
1260
1263
tr.connect(path)
1261
1264
try :
@@ -1272,7 +1275,7 @@ cdef class Loop:
1272
1275
raise ValueError (
1273
1276
' A UNIX Domain Socket was expected, got {!r}' .format(sock))
1274
1277
1275
- waiter = aio_Future( loop = self )
1278
+ waiter = self ._new_future( )
1276
1279
tr = UVPipeTransport.new(self , protocol, None , waiter)
1277
1280
try :
1278
1281
# libuv will make socket non-blocking
@@ -1370,14 +1373,14 @@ cdef class Loop:
1370
1373
def sock_recv (self , sock , n ):
1371
1374
if self ._debug and sock.gettimeout() != 0 :
1372
1375
raise ValueError (" the socket must be non-blocking" )
1373
- fut = aio_Future( loop = self )
1376
+ fut = self ._new_future( )
1374
1377
self ._sock_recv(fut, 0 , sock, n)
1375
1378
return fut
1376
1379
1377
1380
def sock_sendall (self , sock , data ):
1378
1381
if self ._debug and sock.gettimeout() != 0 :
1379
1382
raise ValueError (" the socket must be non-blocking" )
1380
- fut = aio_Future( loop = self )
1383
+ fut = self ._new_future( )
1381
1384
if data:
1382
1385
self ._sock_sendall(fut, 0 , sock, data)
1383
1386
else :
@@ -1387,14 +1390,14 @@ cdef class Loop:
1387
1390
def sock_accept (self , sock ):
1388
1391
if self ._debug and sock.gettimeout() != 0 :
1389
1392
raise ValueError (" the socket must be non-blocking" )
1390
- fut = aio_Future( loop = self )
1393
+ fut = self ._new_future( )
1391
1394
self ._sock_accept(fut, 0 , sock)
1392
1395
return fut
1393
1396
1394
1397
def sock_connect (self , sock , address ):
1395
1398
if self ._debug and sock.gettimeout() != 0 :
1396
1399
raise ValueError (" the socket must be non-blocking" )
1397
- fut = aio_Future( loop = self )
1400
+ fut = self ._new_future( )
1398
1401
try :
1399
1402
if self ._debug:
1400
1403
aio__check_resolved_address(sock, address)
@@ -1462,7 +1465,7 @@ cdef class Loop:
1462
1465
if executable is not None :
1463
1466
args[0 ] = executable
1464
1467
1465
- waiter = aio_Future( loop = self )
1468
+ waiter = self ._new_future( )
1466
1469
protocol = protocol_factory()
1467
1470
proc = UVProcessTransport.new(self , protocol,
1468
1471
args, env, cwd, start_new_session,
@@ -1507,7 +1510,7 @@ cdef class Loop:
1507
1510
UVReadPipeTransport transp
1508
1511
int fileno = os_dup(pipe.fileno())
1509
1512
1510
- waiter = aio_Future( loop = self )
1513
+ waiter = self ._new_future( )
1511
1514
proto = proto_factory()
1512
1515
transp = UVReadPipeTransport.new(self , proto, None , waiter)
1513
1516
transp._add_extra_info(' pipe' , pipe)
@@ -1527,7 +1530,7 @@ cdef class Loop:
1527
1530
UVWritePipeTransport transp
1528
1531
int fileno = os_dup(pipe.fileno())
1529
1532
1530
- waiter = aio_Future( loop = self )
1533
+ waiter = self ._new_future( )
1531
1534
proto = proto_factory()
1532
1535
transp = UVWritePipeTransport.new(self , proto, None , waiter)
1533
1536
transp._add_extra_info(' pipe' , pipe)
0 commit comments