prompt-toolkit / prompt-toolkit/python-prompt-toolkit
No way to detect error or exit out from a patch_stdout situation externally
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 10.6k
- Forks
- 815
- PR merge metrics
- No merged PRs in 30d
Description
Let's assume two programs here, both of which are connected to each other with asynchronous communication.
The first one has this in its code.
from prompt_toolkit import PromptSession
from prompt_toolkit.patch_stdout import patch_stdout
async def my_coroutine():
session = PromptSession()
while True:
with patch_stdout():
result = await session.prompt_async('Say something: ')
print('You said: %s' % result)
And the second one can trigger a
sys.exit()
on the first one.
But here's the thing, the exit - once triggered - is not graceful as even when the first program has apparently exited out, it still remains in the patch_stdout state which means that the nothing turns up on the prompt when being typed.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the PromptSession.prompt_async call and the patch_stdout context used in the issue, then reproduce the behavior when a second program triggers sys.exit() in the first program. Trace how patch_stdout is entered and exited during the asynchronous prompt, and define completion as graceful exit without leaving the prompt in patch_stdout state.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100