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