mirror of
https://github.com/python/cpython.git
synced 2025-10-17 12:18:23 +00:00
Add asyncio.get_running_loop() function. (#4782)
This commit is contained in:
parent
3e9751819a
commit
abae67ebc2
4 changed files with 27 additions and 1 deletions
|
@ -2733,10 +2733,13 @@ class PolicyTests(unittest.TestCase):
|
|||
try:
|
||||
asyncio.set_event_loop_policy(Policy())
|
||||
loop = asyncio.new_event_loop()
|
||||
with self.assertRaisesRegex(RuntimeError, 'no running'):
|
||||
self.assertIs(asyncio.get_running_loop(), None)
|
||||
self.assertIs(asyncio._get_running_loop(), None)
|
||||
|
||||
async def func():
|
||||
self.assertIs(asyncio.get_event_loop(), loop)
|
||||
self.assertIs(asyncio.get_running_loop(), loop)
|
||||
self.assertIs(asyncio._get_running_loop(), loop)
|
||||
|
||||
loop.run_until_complete(func())
|
||||
|
@ -2745,6 +2748,9 @@ class PolicyTests(unittest.TestCase):
|
|||
if loop is not None:
|
||||
loop.close()
|
||||
|
||||
with self.assertRaisesRegex(RuntimeError, 'no running'):
|
||||
self.assertIs(asyncio.get_running_loop(), None)
|
||||
|
||||
self.assertIs(asyncio._get_running_loop(), None)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue