2626import os
2727import sys
2828
29+ from . import coroutines
2930from . import events
3031from . import futures
3132from . import tasks
33+ from .coroutines import coroutine
3234from .log import logger
3335
3436
@@ -118,7 +120,7 @@ def _wakeup(self):
118120 if not waiter .done ():
119121 waiter .set_result (waiter )
120122
121- @tasks . coroutine
123+ @coroutine
122124 def wait_closed (self ):
123125 if self .sockets is None or self .waiters is None :
124126 return
@@ -175,7 +177,7 @@ def _make_write_pipe_transport(self, pipe, protocol, waiter=None,
175177 """Create write pipe transport."""
176178 raise NotImplementedError
177179
178- @tasks . coroutine
180+ @coroutine
179181 def _make_subprocess_transport (self , protocol , args , shell ,
180182 stdin , stdout , stderr , bufsize ,
181183 extra = None , ** kwargs ):
@@ -298,7 +300,7 @@ def call_later(self, delay, callback, *args):
298300
299301 def call_at (self , when , callback , * args ):
300302 """Like call_later(), but uses an absolute time."""
301- if tasks .iscoroutinefunction (callback ):
303+ if coroutines .iscoroutinefunction (callback ):
302304 raise TypeError ("coroutines cannot be used with call_at()" )
303305 if self ._debug :
304306 self ._assert_is_current_event_loop ()
@@ -324,7 +326,7 @@ def call_soon(self, callback, *args):
324326 return handle
325327
326328 def _call_soon (self , callback , args , check_loop ):
327- if tasks .iscoroutinefunction (callback ):
329+ if coroutines .iscoroutinefunction (callback ):
328330 raise TypeError ("coroutines cannot be used with call_soon()" )
329331 if self ._debug and check_loop :
330332 self ._assert_is_current_event_loop ()
@@ -361,7 +363,7 @@ def call_soon_threadsafe(self, callback, *args):
361363 return handle
362364
363365 def run_in_executor (self , executor , callback , * args ):
364- if tasks .iscoroutinefunction (callback ):
366+ if coroutines .iscoroutinefunction (callback ):
365367 raise TypeError ("coroutines cannot be used with run_in_executor()" )
366368 if isinstance (callback , events .Handle ):
367369 assert not args
@@ -389,7 +391,7 @@ def getaddrinfo(self, host, port, *,
389391 def getnameinfo (self , sockaddr , flags = 0 ):
390392 return self .run_in_executor (None , socket .getnameinfo , sockaddr , flags )
391393
392- @tasks . coroutine
394+ @coroutine
393395 def create_connection (self , protocol_factory , host = None , port = None , * ,
394396 ssl = None , family = 0 , proto = 0 , flags = 0 , sock = None ,
395397 local_addr = None , server_hostname = None ):
@@ -505,7 +507,7 @@ def create_connection(self, protocol_factory, host=None, port=None, *,
505507 sock , protocol_factory , ssl , server_hostname )
506508 return transport , protocol
507509
508- @tasks . coroutine
510+ @coroutine
509511 def _create_connection_transport (self , sock , protocol_factory , ssl ,
510512 server_hostname ):
511513 protocol = protocol_factory ()
@@ -521,7 +523,7 @@ def _create_connection_transport(self, sock, protocol_factory, ssl,
521523 yield from waiter
522524 return transport , protocol
523525
524- @tasks . coroutine
526+ @coroutine
525527 def create_datagram_endpoint (self , protocol_factory ,
526528 local_addr = None , remote_addr = None , * ,
527529 family = 0 , proto = 0 , flags = 0 ):
@@ -593,7 +595,7 @@ def create_datagram_endpoint(self, protocol_factory,
593595 transport = self ._make_datagram_transport (sock , protocol , r_addr )
594596 return transport , protocol
595597
596- @tasks . coroutine
598+ @coroutine
597599 def create_server (self , protocol_factory , host = None , port = None ,
598600 * ,
599601 family = socket .AF_UNSPEC ,
@@ -672,23 +674,23 @@ def create_server(self, protocol_factory, host=None, port=None,
672674 self ._start_serving (protocol_factory , sock , ssl , server )
673675 return server
674676
675- @tasks . coroutine
677+ @coroutine
676678 def connect_read_pipe (self , protocol_factory , pipe ):
677679 protocol = protocol_factory ()
678680 waiter = futures .Future (loop = self )
679681 transport = self ._make_read_pipe_transport (pipe , protocol , waiter )
680682 yield from waiter
681683 return transport , protocol
682684
683- @tasks . coroutine
685+ @coroutine
684686 def connect_write_pipe (self , protocol_factory , pipe ):
685687 protocol = protocol_factory ()
686688 waiter = futures .Future (loop = self )
687689 transport = self ._make_write_pipe_transport (pipe , protocol , waiter )
688690 yield from waiter
689691 return transport , protocol
690692
691- @tasks . coroutine
693+ @coroutine
692694 def subprocess_shell (self , protocol_factory , cmd , * , stdin = subprocess .PIPE ,
693695 stdout = subprocess .PIPE , stderr = subprocess .PIPE ,
694696 universal_newlines = False , shell = True , bufsize = 0 ,
@@ -706,7 +708,7 @@ def subprocess_shell(self, protocol_factory, cmd, *, stdin=subprocess.PIPE,
706708 protocol , cmd , True , stdin , stdout , stderr , bufsize , ** kwargs )
707709 return transport , protocol
708710
709- @tasks . coroutine
711+ @coroutine
710712 def subprocess_exec (self , protocol_factory , program , * args ,
711713 stdin = subprocess .PIPE , stdout = subprocess .PIPE ,
712714 stderr = subprocess .PIPE , universal_newlines = False ,
0 commit comments