Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9576a91

Browse files
πŸ“œπŸ€– Added by blurb_it.
1 parent a67cc6f commit 9576a91

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

β€ŽLib/asyncio/runners.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,12 @@ async def main():
176176
raise RuntimeError(
177177
"asyncio.run() cannot be called from a running event loop")
178178

179-
with Runner(debug=debug) as runner:
180-
try:
179+
try:
180+
with Runner(debug=debug) as runner:
181181
events.set_event_loop(runner.get_loop())
182182
return runner.run(main)
183-
finally:
184-
events.set_event_loop(None)
183+
finally:
184+
events.set_event_loop(None)
185185

186186

187187
def _cancel_all_tasks(loop):

β€ŽLib/unittest/async_case.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ def _setupAsyncioRunner(self):
121121
def _tearDownAsyncioRunner(self):
122122
runner = self._asyncioRunner
123123
runner.close()
124-
asyncio.set_event_loop(None)
125124

126125
def run(self, result=None):
127126
self._setupAsyncioRunner()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix :func:`asyncio.run` and :class:`unittest.IsolatedAsyncioTestCase` to always the set event loop as it was done in Python 3.10 and earlier. Patch by Kumar Aditya.

0 commit comments

Comments
Β (0)