Skip to content

Commit c2c6af8

Browse files
Ignore 'invalidate()' if an Application is not running.
1 parent ab51874 commit c2c6af8

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

prompt_toolkit/application/application.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,12 @@ def invalidate(self) -> None:
431431
"""
432432
Thread safe way of sending a repaint trigger to the input event loop.
433433
"""
434+
if not self._is_running:
435+
# Don't schedule a redraw if we're not running.
436+
# Otherwise, `get_event_loop()` in `call_soon_threadsafe` can fail.
437+
# See: https://github.com/dbcli/mycli/issues/797
438+
return
439+
434440
# Never schedule a second redraw, when a previous one has not yet been
435441
# executed. (This should protect against other threads calling
436442
# 'invalidate' many times, resulting in 100% CPU.)

0 commit comments

Comments
 (0)