mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
bpo-39191: Fix RuntimeWarning in asyncio test (GH-17863)
https://bugs.python.org/issue39191
This commit is contained in:
parent
ca94677a62
commit
10ac0cded2
2 changed files with 9 additions and 5 deletions
|
@ -573,7 +573,7 @@ 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 _check_runnung(self):
|
def _check_running(self):
|
||||||
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:
|
||||||
|
@ -583,7 +583,7 @@ class BaseEventLoop(events.AbstractEventLoop):
|
||||||
def run_forever(self):
|
def run_forever(self):
|
||||||
"""Run until stop() is called."""
|
"""Run until stop() is called."""
|
||||||
self._check_closed()
|
self._check_closed()
|
||||||
self._check_runnung()
|
self._check_running()
|
||||||
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()
|
||||||
|
|
||||||
|
@ -615,7 +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()
|
self._check_running()
|
||||||
|
|
||||||
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)
|
||||||
|
|
|
@ -259,8 +259,12 @@ class EventLoopTestsMixin:
|
||||||
self.assertTrue(self.loop.is_running())
|
self.assertTrue(self.loop.is_running())
|
||||||
self.loop.run_until_complete(coro1())
|
self.loop.run_until_complete(coro1())
|
||||||
|
|
||||||
self.assertRaises(
|
with self.assertWarnsRegex(
|
||||||
RuntimeError, self.loop.run_until_complete, coro2())
|
RuntimeWarning,
|
||||||
|
r"coroutine \S+ was never awaited"
|
||||||
|
):
|
||||||
|
self.assertRaises(
|
||||||
|
RuntimeError, self.loop.run_until_complete, coro2())
|
||||||
|
|
||||||
# Note: because of the default Windows timing granularity of
|
# Note: because of the default Windows timing granularity of
|
||||||
# 15.6 msec, we use fairly long sleep times here (~100 msec).
|
# 15.6 msec, we use fairly long sleep times here (~100 msec).
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue