prompt-toolkit / prompt-toolkit/python-prompt-toolkit
feature request: improve writing to stdout/stderr from background thread
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 10.6k
- Forks
- 815
- PR merge metrics
- No merged PRs in 30d
Description
In reference to IPython issue 10406, a useful prompt_toolkit enhancement would be to more gracefully deal with text sent to sys.stdout / sys.stderr from a background thread.
Per @jonathanslenders, this would entail using os.openpty() to create a new pty, then use os.dup2 and fiddle with the file descriptors to make sure that prompt_toolkit writes to the original stdout, while all stdout objects will point to a proxy object while the interface is visible. This would need a reader for the PTY master FD in the event loop.
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 by tracing prompt_toolkit's handling of stdout, stderr, and the event loop; no specific files or tests are named. Review how os.openpty and os.dup2 could support a proxy for stdout objects while the interface is visible, with a reader for the PTY master file descriptor. Done means background-thread output is handled gracefully while prompt_toolkit continues writing to the original stdout.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100