summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio/base_events.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2014-12-04 22:07:47 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2014-12-04 22:07:47 (GMT)
commite80bf0d4a996b3ecda2c2f3cbab10037b9fdcd5e (patch)
tree44657f6e8bee097da3fa5c79db0092a0df6858a4 /Lib/asyncio/base_events.py
parentdd8224e6a483a45d7cf2e7be0fa7d818a3f04c80 (diff)
downloadcpython-e80bf0d4a996b3ecda2c2f3cbab10037b9fdcd5e.zip
cpython-e80bf0d4a996b3ecda2c2f3cbab10037b9fdcd5e.tar.gz
cpython-e80bf0d4a996b3ecda2c2f3cbab10037b9fdcd5e.tar.bz2
Closes #22922: More EventLoop methods fail if the loop is closed. Initial patch
written by Torsten Landschoff. create_task(), call_at(), call_soon(), call_soon_threadsafe() and run_in_executor() now raise an error if the event loop is closed.
Diffstat (limited to 'Lib/asyncio/base_events.py')
-rw-r--r--Lib/asyncio/base_events.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/Lib/asyncio/base_events.py b/Lib/asyncio/base_events.py
index 40dd668..7c38b09 100644
--- a/Lib/asyncio/base_events.py
+++ b/Lib/asyncio/base_events.py
@@ -177,6 +177,7 @@ class BaseEventLoop(events.AbstractEventLoop):
Return a task object.
"""
+ self._check_closed()
task = tasks.Task(coro, loop=self)
if task._source_traceback:
del task._source_traceback[-1]
@@ -360,6 +361,7 @@ class BaseEventLoop(events.AbstractEventLoop):
if (coroutines.iscoroutine(callback)
or coroutines.iscoroutinefunction(callback)):
raise TypeError("coroutines cannot be used with call_at()")
+ self._check_closed()
if self._debug:
self._assert_is_current_event_loop()
timer = events.TimerHandle(when, callback, args, self)
@@ -390,6 +392,7 @@ class BaseEventLoop(events.AbstractEventLoop):
raise TypeError("coroutines cannot be used with call_soon()")
if self._debug and check_loop:
self._assert_is_current_event_loop()
+ self._check_closed()
handle = events.Handle(callback, args, self)
if handle._source_traceback:
del handle._source_traceback[-1]
@@ -426,6 +429,7 @@ class BaseEventLoop(events.AbstractEventLoop):
if (coroutines.iscoroutine(callback)
or coroutines.iscoroutinefunction(callback)):
raise TypeError("coroutines cannot be used with run_in_executor()")
+ self._check_closed()
if isinstance(callback, events.Handle):
assert not args
assert not isinstance(callback, events.TimerHandle)