Show More
@@ -1,10 +1,8 | |||
|
1 | 1 | import asyncio |
|
2 | 2 | import signal |
|
3 | 3 | import sys |
|
4 | import threading | |
|
5 | 4 | |
|
6 | 5 | from IPython.core.debugger import Pdb |
|
7 | ||
|
8 | 6 | from IPython.core.completer import IPCompleter |
|
9 | 7 | from .ptutils import IPythonPTCompleter |
|
10 | 8 | from .shortcuts import create_ipython_shortcuts, suspend_to_bg, cursor_in_leading_ws |
@@ -18,6 +16,7 from pygments.token import Token | |||
|
18 | 16 | from prompt_toolkit.shortcuts.prompt import PromptSession |
|
19 | 17 | from prompt_toolkit.enums import EditingMode |
|
20 | 18 | from prompt_toolkit.formatted_text import PygmentsTokens |
|
19 | from concurrent.futures import ThreadPoolExecutor | |
|
21 | 20 | |
|
22 | 21 | from prompt_toolkit import __version__ as ptk_version |
|
23 | 22 | PTK3 = ptk_version.startswith('3.') |
@@ -30,6 +29,7 class TerminalPdb(Pdb): | |||
|
30 | 29 | Pdb.__init__(self, *args, **kwargs) |
|
31 | 30 | self._ptcomp = None |
|
32 | 31 | self.pt_init(pt_session_options) |
|
32 | self.thread_executor = ThreadPoolExecutor(1) | |
|
33 | 33 | |
|
34 | 34 | def pt_init(self, pt_session_options=None): |
|
35 | 35 | """Initialize the prompt session and the prompt loop |
@@ -102,7 +102,7 class TerminalPdb(Pdb): | |||
|
102 | 102 | if intro is not None: |
|
103 | 103 | self.intro = intro |
|
104 | 104 | if self.intro: |
|
105 | self.stdout.write(str(self.intro)+"\n") | |
|
105 | print(self.intro, file=self.stdout) | |
|
106 | 106 | stop = None |
|
107 | 107 | while not stop: |
|
108 | 108 | if self.cmdqueue: |
@@ -112,24 +112,11 class TerminalPdb(Pdb): | |||
|
112 | 112 | self._ptcomp.ipy_completer.global_namespace = self.curframe.f_globals |
|
113 | 113 | |
|
114 | 114 | # Run the prompt in a different thread. |
|
115 | line = '' | |
|
116 | keyboard_interrupt = False | |
|
117 | ||
|
118 | def in_thread(): | |
|
119 | nonlocal line, keyboard_interrupt | |
|
120 | 115 |
|
|
121 |
|
|
|
116 | line = self.thread_executor.submit(self.pt_app.prompt).result() | |
|
122 | 117 |
|
|
123 |
|
|
|
124 | except KeyboardInterrupt: | |
|
125 | keyboard_interrupt = True | |
|
126 | ||
|
127 | th = threading.Thread(target=in_thread) | |
|
128 | th.start() | |
|
129 | th.join() | |
|
118 | line = "EOF" | |
|
130 | 119 | |
|
131 | if keyboard_interrupt: | |
|
132 | raise KeyboardInterrupt | |
|
133 | 120 | line = self.precmd(line) |
|
134 | 121 | stop = self.onecmd(line) |
|
135 | 122 | stop = self.postcmd(stop, line) |
General Comments 0
You need to be logged in to leave comments.
Login now