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