diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2014-11-20 14:03:52 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2014-11-20 14:03:52 (GMT) |
commit | 2d99d93d11e7908a51fde8de27b7a3584d23cf46 (patch) | |
tree | e52008207c7b1af6298fd742551508e5f0215ec7 /Lib/asyncio/base_events.py | |
parent | c1ad35aae84d5cda4f73696844a87d7764224150 (diff) | |
download | cpython-2d99d93d11e7908a51fde8de27b7a3584d23cf46.zip cpython-2d99d93d11e7908a51fde8de27b7a3584d23cf46.tar.gz cpython-2d99d93d11e7908a51fde8de27b7a3584d23cf46.tar.bz2 |
asyncio: Coroutine objects are now rejected with a TypeError by the following
functions:
* add_signal_handler()
* call_at()
* call_later()
* call_soon()
* call_soon_threadsafe()
* run_in_executor()
Fix also the error message of add_signal_handler() (fix the name of the
function).
Diffstat (limited to 'Lib/asyncio/base_events.py')
-rw-r--r-- | Lib/asyncio/base_events.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/Lib/asyncio/base_events.py b/Lib/asyncio/base_events.py index b6b7123..40dd668 100644 --- a/Lib/asyncio/base_events.py +++ b/Lib/asyncio/base_events.py @@ -357,7 +357,8 @@ class BaseEventLoop(events.AbstractEventLoop): Absolute time corresponds to the event loop's time() method. """ - if coroutines.iscoroutinefunction(callback): + if (coroutines.iscoroutine(callback) + or coroutines.iscoroutinefunction(callback)): raise TypeError("coroutines cannot be used with call_at()") if self._debug: self._assert_is_current_event_loop() @@ -384,7 +385,8 @@ class BaseEventLoop(events.AbstractEventLoop): return handle def _call_soon(self, callback, args, check_loop): - if coroutines.iscoroutinefunction(callback): + if (coroutines.iscoroutine(callback) + or coroutines.iscoroutinefunction(callback)): raise TypeError("coroutines cannot be used with call_soon()") if self._debug and check_loop: self._assert_is_current_event_loop() @@ -421,8 +423,9 @@ class BaseEventLoop(events.AbstractEventLoop): return handle def run_in_executor(self, executor, callback, *args): - if coroutines.iscoroutinefunction(callback): - raise TypeError("Coroutines cannot be used with run_in_executor()") + if (coroutines.iscoroutine(callback) + or coroutines.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) |