@@ -209,7 +209,7 @@ def _wakeup(self):
209209 def wait_closed (self ):
210210 if self .sockets is None or self ._waiters is None :
211211 return
212- waiter = futures . Future ( loop = self ._loop )
212+ waiter = self ._loop . create_future ( )
213213 self ._waiters .append (waiter )
214214 yield from waiter
215215
@@ -243,6 +243,10 @@ def __repr__(self):
243243 % (self .__class__ .__name__ , self .is_running (),
244244 self .is_closed (), self .get_debug ()))
245245
246+ def create_future (self ):
247+ """Create a Future object attached to the loop."""
248+ return futures .Future (loop = self )
249+
246250 def create_task (self , coro ):
247251 """Schedule a coroutine object.
248252
@@ -537,7 +541,7 @@ def run_in_executor(self, executor, func, *args):
537541 assert not args
538542 assert not isinstance (func , events .TimerHandle )
539543 if func ._cancelled :
540- f = futures . Future ( loop = self )
544+ f = self . create_future ( )
541545 f .set_result (None )
542546 return f
543547 func , args = func ._callback , func ._args
@@ -580,7 +584,7 @@ def getaddrinfo(self, host, port, *,
580584 family = 0 , type = 0 , proto = 0 , flags = 0 ):
581585 info = _ipaddr_info (host , port , family , type , proto )
582586 if info is not None :
583- fut = futures . Future ( loop = self )
587+ fut = self . create_future ( )
584588 fut .set_result ([info ])
585589 return fut
586590 elif self ._debug :
@@ -721,7 +725,7 @@ def create_connection(self, protocol_factory, host=None, port=None, *,
721725 def _create_connection_transport (self , sock , protocol_factory , ssl ,
722726 server_hostname ):
723727 protocol = protocol_factory ()
724- waiter = futures . Future ( loop = self )
728+ waiter = self . create_future ( )
725729 if ssl :
726730 sslcontext = None if isinstance (ssl , bool ) else ssl
727731 transport = self ._make_ssl_transport (
@@ -841,7 +845,7 @@ def create_datagram_endpoint(self, protocol_factory,
841845 raise exceptions [0 ]
842846
843847 protocol = protocol_factory ()
844- waiter = futures . Future ( loop = self )
848+ waiter = self . create_future ( )
845849 transport = self ._make_datagram_transport (
846850 sock , protocol , r_addr , waiter )
847851 if self ._debug :
@@ -980,7 +984,7 @@ def create_server(self, protocol_factory, host=None, port=None,
980984 @coroutine
981985 def connect_read_pipe (self , protocol_factory , pipe ):
982986 protocol = protocol_factory ()
983- waiter = futures . Future ( loop = self )
987+ waiter = self . create_future ( )
984988 transport = self ._make_read_pipe_transport (pipe , protocol , waiter )
985989
986990 try :
@@ -997,7 +1001,7 @@ def connect_read_pipe(self, protocol_factory, pipe):
9971001 @coroutine
9981002 def connect_write_pipe (self , protocol_factory , pipe ):
9991003 protocol = protocol_factory ()
1000- waiter = futures . Future ( loop = self )
1004+ waiter = self . create_future ( )
10011005 transport = self ._make_write_pipe_transport (pipe , protocol , waiter )
10021006
10031007 try :
0 commit comments