diff --git a/IPython/terminal/ptshell.py b/IPython/terminal/ptshell.py index 3a7e9a6..7751a05 100644 --- a/IPython/terminal/ptshell.py +++ b/IPython/terminal/ptshell.py @@ -251,8 +251,8 @@ class TerminalInteractiveShell(InteractiveShell): mouse_support=self.mouse_support, **self._layout_options() ) - self.pt_cli = CommandLineInterface(self._app, - eventloop=create_eventloop(self.inputhook)) + self._eventloop = create_eventloop(self.inputhook) + self.pt_cli = CommandLineInterface(self._app, eventloop=self._eventloop) def _make_style_from_name(self, name): """ @@ -383,6 +383,8 @@ class TerminalInteractiveShell(InteractiveShell): except KeyboardInterrupt: print("\nKeyboardInterrupt escaped interact()\n") + self._eventloop.close() + _inputhook = None def inputhook(self, context): if self._inputhook is not None: