summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio/base_events.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2014-06-28 22:46:45 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2014-06-28 22:46:45 (GMT)
commitf951d28ac890063e3ecef56aa8cf851b1152d9dd (patch)
tree71e7b4d00127750cdfff1bce277012622fe2b719 /Lib/asyncio/base_events.py
parent61f32cb5b8358b02c45e0a256c16e505e4c371d2 (diff)
downloadcpython-f951d28ac890063e3ecef56aa8cf851b1152d9dd.zip
cpython-f951d28ac890063e3ecef56aa8cf851b1152d9dd.tar.gz
cpython-f951d28ac890063e3ecef56aa8cf851b1152d9dd.tar.bz2
asyncio: sync with Tulip, add a new asyncio.coroutines module
Diffstat (limited to 'Lib/asyncio/base_events.py')
-rw-r--r--Lib/asyncio/base_events.py28
1 files changed, 15 insertions, 13 deletions
diff --git a/Lib/asyncio/base_events.py b/Lib/asyncio/base_events.py
index 90115e5..c42e7f9 100644
--- a/Lib/asyncio/base_events.py
+++ b/Lib/asyncio/base_events.py
@@ -26,9 +26,11 @@ import time
import os
import sys
+from . import coroutines
from . import events
from . import futures
from . import tasks
+from .coroutines import coroutine
from .log import logger
@@ -118,7 +120,7 @@ class Server(events.AbstractServer):
if not waiter.done():
waiter.set_result(waiter)
- @tasks.coroutine
+ @coroutine
def wait_closed(self):
if self.sockets is None or self.waiters is None:
return
@@ -175,7 +177,7 @@ class BaseEventLoop(events.AbstractEventLoop):
"""Create write pipe transport."""
raise NotImplementedError
- @tasks.coroutine
+ @coroutine
def _make_subprocess_transport(self, protocol, args, shell,
stdin, stdout, stderr, bufsize,
extra=None, **kwargs):
@@ -298,7 +300,7 @@ class BaseEventLoop(events.AbstractEventLoop):
def call_at(self, when, callback, *args):
"""Like call_later(), but uses an absolute time."""
- if tasks.iscoroutinefunction(callback):
+ if coroutines.iscoroutinefunction(callback):
raise TypeError("coroutines cannot be used with call_at()")
if self._debug:
self._assert_is_current_event_loop()
@@ -324,7 +326,7 @@ class BaseEventLoop(events.AbstractEventLoop):
return handle
def _call_soon(self, callback, args, check_loop):
- if tasks.iscoroutinefunction(callback):
+ if coroutines.iscoroutinefunction(callback):
raise TypeError("coroutines cannot be used with call_soon()")
if self._debug and check_loop:
self._assert_is_current_event_loop()
@@ -361,7 +363,7 @@ class BaseEventLoop(events.AbstractEventLoop):
return handle
def run_in_executor(self, executor, callback, *args):
- if tasks.iscoroutinefunction(callback):
+ if coroutines.iscoroutinefunction(callback):
raise TypeError("coroutines cannot be used with run_in_executor()")
if isinstance(callback, events.Handle):
assert not args
@@ -389,7 +391,7 @@ class BaseEventLoop(events.AbstractEventLoop):
def getnameinfo(self, sockaddr, flags=0):
return self.run_in_executor(None, socket.getnameinfo, sockaddr, flags)
- @tasks.coroutine
+ @coroutine
def create_connection(self, protocol_factory, host=None, port=None, *,
ssl=None, family=0, proto=0, flags=0, sock=None,
local_addr=None, server_hostname=None):
@@ -505,7 +507,7 @@ class BaseEventLoop(events.AbstractEventLoop):
sock, protocol_factory, ssl, server_hostname)
return transport, protocol
- @tasks.coroutine
+ @coroutine
def _create_connection_transport(self, sock, protocol_factory, ssl,
server_hostname):
protocol = protocol_factory()
@@ -521,7 +523,7 @@ class BaseEventLoop(events.AbstractEventLoop):
yield from waiter
return transport, protocol
- @tasks.coroutine
+ @coroutine
def create_datagram_endpoint(self, protocol_factory,
local_addr=None, remote_addr=None, *,
family=0, proto=0, flags=0):
@@ -593,7 +595,7 @@ class BaseEventLoop(events.AbstractEventLoop):
transport = self._make_datagram_transport(sock, protocol, r_addr)
return transport, protocol
- @tasks.coroutine
+ @coroutine
def create_server(self, protocol_factory, host=None, port=None,
*,
family=socket.AF_UNSPEC,
@@ -672,7 +674,7 @@ class BaseEventLoop(events.AbstractEventLoop):
self._start_serving(protocol_factory, sock, ssl, server)
return server
- @tasks.coroutine
+ @coroutine
def connect_read_pipe(self, protocol_factory, pipe):
protocol = protocol_factory()
waiter = futures.Future(loop=self)
@@ -680,7 +682,7 @@ class BaseEventLoop(events.AbstractEventLoop):
yield from waiter
return transport, protocol
- @tasks.coroutine
+ @coroutine
def connect_write_pipe(self, protocol_factory, pipe):
protocol = protocol_factory()
waiter = futures.Future(loop=self)
@@ -688,7 +690,7 @@ class BaseEventLoop(events.AbstractEventLoop):
yield from waiter
return transport, protocol
- @tasks.coroutine
+ @coroutine
def subprocess_shell(self, protocol_factory, cmd, *, stdin=subprocess.PIPE,
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
universal_newlines=False, shell=True, bufsize=0,
@@ -706,7 +708,7 @@ class BaseEventLoop(events.AbstractEventLoop):
protocol, cmd, True, stdin, stdout, stderr, bufsize, **kwargs)
return transport, protocol
- @tasks.coroutine
+ @coroutine
def subprocess_exec(self, protocol_factory, program, *args,
stdin=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, universal_newlines=False,