diff options
author | Andrew Svetlov <andrew.svetlov@gmail.com> | 2020-01-04 11:49:11 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-04 11:49:11 +0200 |
commit | 867d8333ce6a7f74191ad464acc609d4a04e4acb (patch) | |
tree | 3621ba91c0847eaf941c760fd12631fff1e8db7d /Lib/asyncio | |
parent | aa3efea9c5f4d25afc3fa4cfd5e6d789943893c9 (diff) | |
download | cpython-git-867d8333ce6a7f74191ad464acc609d4a04e4acb.tar.gz |
[3.8] bpo-39191: Don't spawn a task before failing (GH-17796) (GH-17820)
(cherry picked from commit 3a5de511596f17575de082dcb8d43d63b2bd2da9)
Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
Diffstat (limited to 'Lib/asyncio')
-rw-r--r-- | Lib/asyncio/base_events.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/Lib/asyncio/base_events.py b/Lib/asyncio/base_events.py index bfd40115be..aedf0c5e6d 100644 --- a/Lib/asyncio/base_events.py +++ b/Lib/asyncio/base_events.py @@ -547,14 +547,17 @@ class BaseEventLoop(events.AbstractEventLoop): 'asyncgen': agen }) - def run_forever(self): - """Run until stop() is called.""" - self._check_closed() + def _check_runnung(self): if self.is_running(): raise RuntimeError('This event loop is already running') if events._get_running_loop() is not None: raise RuntimeError( 'Cannot run the event loop while another loop is running') + + def run_forever(self): + """Run until stop() is called.""" + self._check_closed() + self._check_runnung() self._set_coroutine_origin_tracking(self._debug) self._thread_id = threading.get_ident() @@ -586,6 +589,7 @@ class BaseEventLoop(events.AbstractEventLoop): Return the Future's result, or raise its exception. """ self._check_closed() + self._check_runnung() new_task = not futures.isfuture(future) future = tasks.ensure_future(future, loop=self) |