i try to use this sequence of code but when i i execute session.prompt at the second time i have this error : assert app._is_running
is there a better sequence of coding ?
our_history = FileHistory('.example-history-file')
session = PromptSession(history=our_history)
batch = GBatch()
args = batch.parser.parse_args()
batch.init(args)
print ("Welcome ", batch.player)
args.func(args)
guru = True
while True:
with patch_stdout():
cmd = session.prompt(" >> ")
if cmd:
args = batch.parser.parse_args(cmd.split())
args.cmde = cmd
args.func(args)
if batch.bye:
break
here the trace
AssertionError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/bruno/gsprompt/venv/lib/python3.7/site-packages/prompt_toolkit/eventloop/base.py", line 129, in call_exception_handler
self._exception_handler(context)
File "/Users/bruno/gsprompt/venv/lib/python3.7/site-packages/prompt_toolkit/application/application.py", line 702, in handle_exception
run_coroutine_in_terminal(print_exception)
File "/Users/bruno/gsprompt/venv/lib/python3.7/site-packages/prompt_toolkit/application/run_in_terminal.py", line 62, in run_coroutine_in_terminal
assert app._is_running
AssertionError
I'm not sure what's going on, but a few things you can try:
Remove the "patch_stdout" code.
Remove any line, until it it starts working.
Can you give me a minimum example with only prompt_toolkit code to reproduce the issue, and then the key presses that generate this error?
i try to use this sequence of code but when i i execute session.prompt at the second time i have this error : assert app._is_running
is there a better sequence of coding ? our_history = FileHistory('.example-history-file') session = PromptSession(history=our_history) batch = GBatch() args = batch.parser.parse_args() batch.init(args) print ("Welcome ", batch.player) args.func(args) guru = True
here the trace AssertionError
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/Users/bruno/gsprompt/venv/lib/python3.7/site-packages/prompt_toolkit/eventloop/base.py", line 129, in call_exception_handler self._exception_handler(context) File "/Users/bruno/gsprompt/venv/lib/python3.7/site-packages/prompt_toolkit/application/application.py", line 702, in handle_exception run_coroutine_in_terminal(print_exception) File "/Users/bruno/gsprompt/venv/lib/python3.7/site-packages/prompt_toolkit/application/run_in_terminal.py", line 62, in run_coroutine_in_terminal assert app._is_running AssertionError