##// END OF EJS Templates
Use prompt_toolkit.application.create_app_session for debugger prompt...
Maor Kleinberger -
Show More
@@ -10,6 +10,7 b' from . import embed'
10 10
11 11 from pathlib import Path
12 12 from pygments.token import Token
13 from prompt_toolkit.application import create_app_session
13 14 from prompt_toolkit.shortcuts.prompt import PromptSession
14 15 from prompt_toolkit.enums import EditingMode
15 16 from prompt_toolkit.formatted_text import PygmentsTokens
@@ -96,6 +97,17 b' class TerminalPdb(Pdb):'
96 97 self.pt_loop = asyncio.new_event_loop()
97 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 111 def cmdloop(self, intro=None):
100 112 """Repeatedly issue a prompt, accept input, parse an initial prefix
101 113 off the received input, and dispatch to action methods, passing them
@@ -129,9 +141,7 b' class TerminalPdb(Pdb):'
129 141 # Run the prompt in a different thread.
130 142 if not _use_simple_prompt:
131 143 try:
132 line = self.thread_executor.submit(
133 self.pt_app.prompt
134 ).result()
144 line = self.thread_executor.submit(self._prompt).result()
135 145 except EOFError:
136 146 line = "EOF"
137 147 else:
General Comments 0
You need to be logged in to leave comments. Login now