(self)
| 1019 | self.run_cell(code, store_history=True) |
| 1020 | |
| 1021 | def mainloop(self): |
| 1022 | # An extra layer of protection in case someone mashing Ctrl-C breaks |
| 1023 | # out of our internal code. |
| 1024 | while True: |
| 1025 | try: |
| 1026 | self.interact() |
| 1027 | break |
| 1028 | except KeyboardInterrupt as e: |
| 1029 | print("\n%s escaped interact()\n" % type(e).__name__) |
| 1030 | finally: |
| 1031 | # An interrupt during the eventloop will mess up the |
| 1032 | # internal state of the prompt_toolkit library. |
| 1033 | # Stopping the eventloop fixes this, see |
| 1034 | # https://github.com/ipython/ipython/pull/9867 |
| 1035 | if hasattr(self, '_eventloop'): |
| 1036 | self._eventloop.stop() |
| 1037 | |
| 1038 | self.restore_term_title() |
| 1039 | |
| 1040 | # try to call some at-exit operation optimistically as some things can't |
| 1041 | # be done during interpreter shutdown. this is technically inaccurate as |
| 1042 | # this make mainlool not re-callable, but that should be a rare if not |
| 1043 | # in existent use case. |
| 1044 | |
| 1045 | self._atexit_once() |
| 1046 | |
| 1047 | _inputhook = None |
| 1048 | def inputhook(self, context): |
nothing calls this directly
no test coverage detected