Show More
@@ -913,6 +913,10 class TerminalInteractiveShell(InteractiveShell): | |||||
913 |
|
913 | |||
914 | active_eventloop = None |
|
914 | active_eventloop = None | |
915 | def enable_gui(self, gui=None): |
|
915 | def enable_gui(self, gui=None): | |
|
916 | if self._inputhook is None and gui is None: | |||
|
917 | print("No event loop hook running.") | |||
|
918 | return | |||
|
919 | ||||
916 | if self._inputhook is not None and gui is not None: |
|
920 | if self._inputhook is not None and gui is not None: | |
917 | print( |
|
921 | print( | |
918 | f"Shell is already running a gui event loop for {self.active_eventloop}. " |
|
922 | f"Shell is already running a gui event loop for {self.active_eventloop}. " | |
@@ -920,7 +924,6 class TerminalInteractiveShell(InteractiveShell): | |||||
920 | ) |
|
924 | ) | |
921 | return |
|
925 | return | |
922 | if self._inputhook is not None and gui is None: |
|
926 | if self._inputhook is not None and gui is None: | |
923 | print('GUI event loop hook disabled.') |
|
|||
924 | self.active_eventloop = self._inputhook = None |
|
927 | self.active_eventloop = self._inputhook = None | |
925 |
|
928 | |||
926 | if gui and (gui not in {"inline", "webagg"}): |
|
929 | if gui and (gui not in {"inline", "webagg"}): | |
@@ -940,15 +943,18 class TerminalInteractiveShell(InteractiveShell): | |||||
940 | # same event loop as the rest of the code. don't use an actual |
|
943 | # same event loop as the rest of the code. don't use an actual | |
941 | # input hook. (Asyncio is not made for nesting event loops.) |
|
944 | # input hook. (Asyncio is not made for nesting event loops.) | |
942 | self.pt_loop = get_asyncio_loop() |
|
945 | self.pt_loop = get_asyncio_loop() | |
|
946 | print("Installed asyncio event loop hook.") | |||
943 |
|
947 | |||
944 | elif self._inputhook: |
|
948 | elif self._inputhook: | |
945 | # If an inputhook was set, create a new asyncio event loop with |
|
949 | # If an inputhook was set, create a new asyncio event loop with | |
946 | # this inputhook for the prompt. |
|
950 | # this inputhook for the prompt. | |
947 | self.pt_loop = new_eventloop_with_inputhook(self._inputhook) |
|
951 | self.pt_loop = new_eventloop_with_inputhook(self._inputhook) | |
|
952 | print(f"Installed {self.active_eventloop} event loop hook.") | |||
948 | else: |
|
953 | else: | |
949 | # When there's no inputhook, run the prompt in a separate |
|
954 | # When there's no inputhook, run the prompt in a separate | |
950 | # asyncio event loop. |
|
955 | # asyncio event loop. | |
951 | self.pt_loop = asyncio.new_event_loop() |
|
956 | self.pt_loop = asyncio.new_event_loop() | |
|
957 | print("GUI event loop hook disabled.") | |||
952 |
|
958 | |||
953 | # Run !system commands directly, not through pipes, so terminal programs |
|
959 | # Run !system commands directly, not through pipes, so terminal programs | |
954 | # work correctly. |
|
960 | # work correctly. |
General Comments 0
You need to be logged in to leave comments.
Login now