From 4352b6b4f6f41c0dc408bfa791347632096d1c6e 2019-12-01 01:04:28 From: Matthias Bussonnier Date: 2019-12-01 01:04:28 Subject: [PATCH] Merge pull request #11990 from jonathanslenders/asyncio-inputhook-improvements Improve cleanup of asyncio input hook. --- diff --git a/IPython/terminal/pt_inputhooks/asyncio.py b/IPython/terminal/pt_inputhooks/asyncio.py index 53d4974..e286038 100644 --- a/IPython/terminal/pt_inputhooks/asyncio.py +++ b/IPython/terminal/pt_inputhooks/asyncio.py @@ -38,6 +38,9 @@ def inputhook(context): def stop(): loop.stop() - loop.add_reader(context.fileno(), stop) - context.fileno() - loop.run_forever() + fileno = context.fileno() + loop.add_reader(fileno, stop) + try: + loop.run_forever() + finally: + loop.remove_reader(fileno)