##// END OF EJS Templates
Use prompt_toolkit.application.create_app_session for debugger prompt (#13889)...
Matthias Bussonnier -
r28319:984ec854 merge
parent child Browse files
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
@@ -95,6 +96,17 b' class TerminalPdb(Pdb):'
95 96 self.pt_loop = asyncio.new_event_loop()
96 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 110 def cmdloop(self, intro=None):
99 111 """Repeatedly issue a prompt, accept input, parse an initial prefix
100 112 off the received input, and dispatch to action methods, passing them
@@ -128,9 +140,7 b' class TerminalPdb(Pdb):'
128 140 # Run the prompt in a different thread.
129 141 if not _use_simple_prompt:
130 142 try:
131 line = self.thread_executor.submit(
132 self.pt_app.prompt
133 ).result()
143 line = self.thread_executor.submit(self._prompt).result()
134 144 except EOFError:
135 145 line = "EOF"
136 146 else:
General Comments 0
You need to be logged in to leave comments. Login now