Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita545749

Browse files
gh-130145: fixloop.run_forever when loop is already running (#130146)
1 parenta05433f commita545749

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

‎Lib/asyncio/base_events.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -671,8 +671,8 @@ def _run_forever_cleanup(self):
671671

672672
defrun_forever(self):
673673
"""Run until stop() is called."""
674+
self._run_forever_setup()
674675
try:
675-
self._run_forever_setup()
676676
whileTrue:
677677
self._run_once()
678678
ifself._stopping:

‎Lib/test/test_asyncio/test_events.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3004,6 +3004,22 @@ async def main():
30043004
self.loop.run_until_complete(main()),
30053005
'hello')
30063006

3007+
deftest_get_running_loop_already_running(self):
3008+
asyncdefmain():
3009+
running_loop=asyncio.get_running_loop()
3010+
loop=asyncio.new_event_loop()
3011+
try:
3012+
loop.run_forever()
3013+
exceptRuntimeError:
3014+
pass
3015+
else:
3016+
self.fail("RuntimeError not raised")
3017+
3018+
self.assertIs(asyncio.get_running_loop(),running_loop)
3019+
3020+
self.loop.run_until_complete(main())
3021+
3022+
30073023
deftest_get_event_loop_returns_running_loop(self):
30083024
classTestError(Exception):
30093025
pass
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix:meth:`!asyncio.AbstractEventloop.run_forever` when another loop is already running.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp