Skip to content

Commit 875fd2a

Browse files
committed
Employ asyncio.Runner in the asyncio REPL
1 parent 393aaad commit 875fd2a

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Lib/asyncio/__main__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,8 @@ def interrupt(self) -> None:
192192
from _pyrepl.main import CAN_USE_PYREPL
193193

194194
return_code = 0
195-
loop = asyncio.new_event_loop()
196-
asyncio.set_event_loop(loop)
195+
runner = asyncio.Runner()
196+
loop = runner.get_loop()
197197

198198
repl_locals = {'asyncio': asyncio}
199199
for key in {'__name__', '__package__',
@@ -245,4 +245,5 @@ def interrupt(self) -> None:
245245
break
246246

247247
console.write('exiting asyncio REPL...\n')
248+
runner.close()
248249
sys.exit(return_code)

0 commit comments

Comments
 (0)