Open ale-dd opened 3 years ago
If you can make a reproducer, that would be nice.
I wonder why we are getting this error. I don't think we turn stdout into non blocking mode. And I wonder whether we could suppress this exception.
full-screen-demo.py and a few other full screen examples do crash with a different exception when running under uvloop.
You can reproduce the exact same exception as above by hitting CTRL-C while running progress-bar/a-lot-of-parallel-tasks.py
thank you!
diff --git a/examples/full-screen/full-screen-demo.py b/examples/full-screen/full-screen-demo.py index 7e251f6a..093f4b18 100755 --- a/examples/full-screen/full-screen-demo.py +++ b/examples/full-screen/full-screen-demo.py @@ -1,6 +1,7 @@
""" """ +import uvloop; uvloop.install() from pygments.lexers.html import HtmlLexer
from prompt_toolkit.application import Application diff --git a/examples/progress-bar/a-lot-of-parallel-tasks.py b/examples/progress-bar/a-lot-of-parallel-tasks.py index 31110ac0..0aab452a 100755 --- a/examples/progress-bar/a-lot-of-parallel-tasks.py +++ b/examples/progress-bar/a-lot-of-parallel-tasks.py @@ -2,6 +2,7 @@ """ More complex demonstration of what's possible with the progress bar. """ +import uvloop; uvloop.install() import random import threading import time
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.