prompt-toolkit / prompt-toolkit/python-prompt-toolkit

Issues with uvloop

Open
#1,230 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
10.6k
Forks
815
PR merge metrics
No merged PRs in 30d

Description

I have a prompt_toolkit application that works well with uvloop so long as the terminal doesn't get overly crowded and cluttered. When too many elements are present (and in actuality not so many), it only works well without uvloop. With uvloop it either has some issue whereby widgets will start drifting down because of what looks like some extra carriage return upon refresh, or it will cause the following exception:

`Unhandled exception in event loop:
File "uvloop/cbhandles.pyx", line 68, in uvloop.loop.Handle._run
File "/usr/lib/python3.9/site-packages/prompt_toolkit/eventloop/utils.py", line 72, in schedule
func()
File "/usr/lib/python3.9/site-packages/prompt_toolkit/application/application.py", line 456, in redraw
self._redraw()
File "/usr/lib/python3.9/site-packages/prompt_toolkit/application/application.py", line 523, in _redraw
self.context.run(run_in_context)
File "/usr/lib/python3.9/site-packages/prompt_toolkit/application/application.py", line 509, in run_in_context
self.renderer.render(self, self.layout)
File "/usr/lib/python3.9/site-packages/prompt_toolkit/renderer.py", line 631, in render
output.flush()
File "/usr/lib/python3.9/site-packages/prompt_toolkit/output/vt100.py", line 651, in flush
out.write(data.encode(self.stdout.encoding or "utf-8", "replace"))

Exception [Errno 11] write could not complete without blocking`

I could try and come up with the minimum amount of code to reproduce this if you are interested.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the crowded-terminal behavior with uvloop, then trace the redraw path in prompt_toolkit/application/application.py and renderer.py through output/vt100.py:651. A useful result would identify the cause of the drifting widgets or the nonblocking write exception and provide a verified correction, but the issue does not include a minimal reproducer or named test.

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
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.