mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
gh-130145: fix loop.run_forever
when loop is already running (#130146)
This commit is contained in:
parent
a05433f24a
commit
a545749b0e
3 changed files with 18 additions and 1 deletions
|
@ -3004,6 +3004,22 @@ class GetEventLoopTestsMixin:
|
|||
self.loop.run_until_complete(main()),
|
||||
'hello')
|
||||
|
||||
def test_get_running_loop_already_running(self):
|
||||
async def main():
|
||||
running_loop = asyncio.get_running_loop()
|
||||
loop = asyncio.new_event_loop()
|
||||
try:
|
||||
loop.run_forever()
|
||||
except RuntimeError:
|
||||
pass
|
||||
else:
|
||||
self.fail("RuntimeError not raised")
|
||||
|
||||
self.assertIs(asyncio.get_running_loop(), running_loop)
|
||||
|
||||
self.loop.run_until_complete(main())
|
||||
|
||||
|
||||
def test_get_event_loop_returns_running_loop(self):
|
||||
class TestError(Exception):
|
||||
pass
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue