Skip to content
5 changes: 3 additions & 2 deletions Lib/asyncio/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,8 @@ def interrupt(self) -> None:
from _pyrepl.main import CAN_USE_PYREPL

return_code = 0
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
runner = asyncio.Runner()
loop = runner.get_loop()

repl_locals = {'asyncio': asyncio}
for key in {'__name__', '__package__',
Expand Down Expand Up @@ -240,4 +240,5 @@ def interrupt(self) -> None:
break

console.write('exiting asyncio REPL...\n')
runner.close()
sys.exit(return_code)
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
The asyncio REPL now properly closes the loop upon the end of session.
Contributed by Bartosz Sławecki.
Loading