Show More
@@ -10,6 +10,7 b' from . import embed' | |||||
10 |
|
10 | |||
11 | from pathlib import Path |
|
11 | from pathlib import Path | |
12 | from pygments.token import Token |
|
12 | from pygments.token import Token | |
|
13 | from prompt_toolkit.application import create_app_session | |||
13 | from prompt_toolkit.shortcuts.prompt import PromptSession |
|
14 | from prompt_toolkit.shortcuts.prompt import PromptSession | |
14 | from prompt_toolkit.enums import EditingMode |
|
15 | from prompt_toolkit.enums import EditingMode | |
15 | from prompt_toolkit.formatted_text import PygmentsTokens |
|
16 | from prompt_toolkit.formatted_text import PygmentsTokens | |
@@ -95,6 +96,17 b' class TerminalPdb(Pdb):' | |||||
95 | self.pt_loop = asyncio.new_event_loop() |
|
96 | self.pt_loop = asyncio.new_event_loop() | |
96 | self.pt_app = PromptSession(**options) |
|
97 | self.pt_app = PromptSession(**options) | |
97 |
|
98 | |||
|
99 | def _prompt(self): | |||
|
100 | """ | |||
|
101 | In case other prompt_toolkit apps have to run in parallel to this one (e.g. in madbg), | |||
|
102 | create_app_session must be used to prevent mixing up between them. According to the prompt_toolkit docs: | |||
|
103 | ||||
|
104 | > If you need multiple applications running at the same time, you have to create a separate | |||
|
105 | > `AppSession` using a `with create_app_session():` block. | |||
|
106 | """ | |||
|
107 | with create_app_session(): | |||
|
108 | return self.pt_app.prompt() | |||
|
109 | ||||
98 | def cmdloop(self, intro=None): |
|
110 | def cmdloop(self, intro=None): | |
99 | """Repeatedly issue a prompt, accept input, parse an initial prefix |
|
111 | """Repeatedly issue a prompt, accept input, parse an initial prefix | |
100 | off the received input, and dispatch to action methods, passing them |
|
112 | off the received input, and dispatch to action methods, passing them | |
@@ -128,9 +140,7 b' class TerminalPdb(Pdb):' | |||||
128 | # Run the prompt in a different thread. |
|
140 | # Run the prompt in a different thread. | |
129 | if not _use_simple_prompt: |
|
141 | if not _use_simple_prompt: | |
130 | try: |
|
142 | try: | |
131 | line = self.thread_executor.submit( |
|
143 | line = self.thread_executor.submit(self._prompt).result() | |
132 | self.pt_app.prompt |
|
|||
133 | ).result() |
|
|||
134 | except EOFError: |
|
144 | except EOFError: | |
135 | line = "EOF" |
|
145 | line = "EOF" | |
136 | else: |
|
146 | else: |
General Comments 0
You need to be logged in to leave comments.
Login now