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

Skip to content

Commit 5332000

Browse files
committed
Allow starting TerminalInteractiveShell more than once
1. always start with keep_running=True in `interact()` 2. don't close eventloop at end of mainloop (not sure this is the right thing to do)
1 parent 345bf7d commit 5332000

1 file changed

Lines changed: 1 addition & 3 deletions

File tree

IPython/terminal/interactiveshell.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,7 @@ def interact(self, display_banner=DISPLAY_BANNER_DEPRECATED):
415415
if display_banner is not DISPLAY_BANNER_DEPRECATED:
416416
warn('interact `display_banner` argument is deprecated since IPython 5.0. Call `show_banner()` if needed.', DeprecationWarning, stacklevel=2)
417417

418+
self.keep_running = True
418419
while self.keep_running:
419420
print(self.separate_in, end='')
420421

@@ -440,9 +441,6 @@ def mainloop(self, display_banner=DISPLAY_BANNER_DEPRECATED):
440441
break
441442
except KeyboardInterrupt:
442443
print("\nKeyboardInterrupt escaped interact()\n")
443-
444-
if hasattr(self, '_eventloop'):
445-
self._eventloop.close()
446444

447445
_inputhook = None
448446
def inputhook(self, context):

0 commit comments

Comments
 (0)