@@ -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
@@ -536,7 +540,7 @@ def run_in_executor(self, executor, func, *args):
536540 assert not args
537541 assert not isinstance (func , events .TimerHandle )
538542 if func ._cancelled :
539- f = futures . Future ( loop = self )
543+ f = self . create_future ( )
540544 f .set_result (None )
541545 return f
542546 func , args = func ._callback , func ._args
@@ -579,7 +583,7 @@ def getaddrinfo(self, host, port, *,
579583 family = 0 , type = 0 , proto = 0 , flags = 0 ):
580584 info = _ipaddr_info (host , port , family , type , proto )
581585 if info is not None :
582- fut = futures . Future ( loop = self )
586+ fut = self . create_future ( )
583587 fut .set_result ([info ])
584588 return fut
585589 elif self ._debug :
@@ -720,7 +724,7 @@ def create_connection(self, protocol_factory, host=None, port=None, *,
720724 def _create_connection_transport (self , sock , protocol_factory , ssl ,
721725 server_hostname ):
722726 protocol = protocol_factory ()
723- waiter = futures . Future ( loop = self )
727+ waiter = self . create_future ( )
724728 if ssl :
725729 sslcontext = None if isinstance (ssl , bool ) else ssl
726730 transport = self ._make_ssl_transport (
@@ -840,7 +844,7 @@ def create_datagram_endpoint(self, protocol_factory,
840844 raise exceptions [0 ]
841845
842846 protocol = protocol_factory ()
843- waiter = futures . Future ( loop = self )
847+ waiter = self . create_future ( )
844848 transport = self ._make_datagram_transport (
845849 sock , protocol , r_addr , waiter )
846850 if self ._debug :
@@ -979,7 +983,7 @@ def create_server(self, protocol_factory, host=None, port=None,
979983 @coroutine
980984 def connect_read_pipe (self , protocol_factory , pipe ):
981985 protocol = protocol_factory ()
982- waiter = futures . Future ( loop = self )
986+ waiter = self . create_future ( )
983987 transport = self ._make_read_pipe_transport (pipe , protocol , waiter )
984988
985989 try :
@@ -996,7 +1000,7 @@ def connect_read_pipe(self, protocol_factory, pipe):
9961000 @coroutine
9971001 def connect_write_pipe (self , protocol_factory , pipe ):
9981002 protocol = protocol_factory ()
999- waiter = futures . Future ( loop = self )
1003+ waiter = self . create_future ( )
10001004 transport = self ._make_write_pipe_transport (pipe , protocol , waiter )
10011005
10021006 try :
0 commit comments