summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio/base_events.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2014-02-11 10:34:30 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2014-02-11 10:34:30 (GMT)
commita125497ea302aff937a5c59f98c39dba4f1ab59b (patch)
tree3c4ef537c6bba46a544fefabae9b59c60a289c1b /Lib/asyncio/base_events.py
parent1db2ba3a92a435e871800612a14a9dfc9e760fab (diff)
downloadcpython-a125497ea302aff937a5c59f98c39dba4f1ab59b.zip
cpython-a125497ea302aff937a5c59f98c39dba4f1ab59b.tar.gz
cpython-a125497ea302aff937a5c59f98c39dba4f1ab59b.tar.bz2
asyncio, Tulip issue 126: call_soon(), call_soon_threadsafe(), call_later(),
call_at() and run_in_executor() now raise a TypeError if the callback is a coroutine function.
Diffstat (limited to 'Lib/asyncio/base_events.py')
-rw-r--r--Lib/asyncio/base_events.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/asyncio/base_events.py b/Lib/asyncio/base_events.py
index 48b3ee3..4b7b161 100644
--- a/Lib/asyncio/base_events.py
+++ b/Lib/asyncio/base_events.py
@@ -227,6 +227,8 @@ class BaseEventLoop(events.AbstractEventLoop):
def call_at(self, when, callback, *args):
"""Like call_later(), but uses an absolute time."""
+ if tasks.iscoroutinefunction(callback):
+ raise TypeError("coroutines cannot be used with call_at()")
timer = events.TimerHandle(when, callback, args)
heapq.heappush(self._scheduled, timer)
return timer
@@ -241,6 +243,8 @@ class BaseEventLoop(events.AbstractEventLoop):
Any positional arguments after the callback will be passed to
the callback when it is called.
"""
+ if tasks.iscoroutinefunction(callback):
+ raise TypeError("coroutines cannot be used with call_soon()")
handle = events.Handle(callback, args)
self._ready.append(handle)
return handle
@@ -252,6 +256,8 @@ class BaseEventLoop(events.AbstractEventLoop):
return handle
def run_in_executor(self, executor, callback, *args):
+ if tasks.iscoroutinefunction(callback):
+ raise TypeError("coroutines cannot be used with run_in_executor()")
if isinstance(callback, events.Handle):
assert not args
assert not isinstance(callback, events.TimerHandle)