parent
e02ab59fdf
commit
3a5de51159
@ -573,14 +573,17 @@ class BaseEventLoop(events.AbstractEventLoop):
|
|||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
self.call_soon_threadsafe(future.set_exception, ex)
|
self.call_soon_threadsafe(future.set_exception, ex)
|
||||||
|
|
||||||
def run_forever(self):
|
def _check_runnung(self):
|
||||||
"""Run until stop() is called."""
|
|
||||||
self._check_closed()
|
|
||||||
if self.is_running():
|
if self.is_running():
|
||||||
raise RuntimeError('This event loop is already running')
|
raise RuntimeError('This event loop is already running')
|
||||||
if events._get_running_loop() is not None:
|
if events._get_running_loop() is not None:
|
||||||
raise RuntimeError(
|
raise RuntimeError(
|
||||||
'Cannot run the event loop while another loop is running')
|
'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._set_coroutine_origin_tracking(self._debug)
|
||||||
self._thread_id = threading.get_ident()
|
self._thread_id = threading.get_ident()
|
||||||
|
|
||||||
@ -612,6 +615,7 @@ class BaseEventLoop(events.AbstractEventLoop):
|
|||||||
Return the Future's result, or raise its exception.
|
Return the Future's result, or raise its exception.
|
||||||
"""
|
"""
|
||||||
self._check_closed()
|
self._check_closed()
|
||||||
|
self._check_runnung()
|
||||||
|
|
||||||
new_task = not futures.isfuture(future)
|
new_task = not futures.isfuture(future)
|
||||||
future = tasks.ensure_future(future, loop=self)
|
future = tasks.ensure_future(future, loop=self)
|
||||||
|
@ -0,0 +1,3 @@
|
|||||||
|
Perform a check for running loop before starting a new task in
|
||||||
|
``loop.run_until_complete()`` to fail fast; it prevents the side effect of
|
||||||
|
new task spawning before exception raising.
|
Loading…
x
Reference in New Issue
Block a user