summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Slenders <jonathan@slenders.be>2016-01-05 05:53:25 +0100
committerJonathan Slenders <jonathan@slenders.be>2016-01-05 05:53:25 +0100
commitd2deee66f364aa5245eacb790153e8637bfa7b59 (patch)
tree4c6e86580f0e49f98bc6dfadfeade6fcdb9d1058
parent1f8c1054cfd9a3b87a61537ae09af596ad326122 (diff)
Make max_render_postpone_time configurable. (Disable by default -- it did more bad than good.)
-rw-r--r--prompt_toolkit/interface.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/prompt_toolkit/interface.py b/prompt_toolkit/interface.py
index 00531816..2d6f6105 100644
--- a/prompt_toolkit/interface.py
+++ b/prompt_toolkit/interface.py
@@ -89,6 +89,10 @@ class CommandLineInterface(object):
#: rendering.
self.render_counter = 0
+ #: When there is high CPU, postpone the renderering max x seconds.
+ #: '0' means: don't postpone. '.5' means: try to draw at least twice a second.
+ self.max_render_postpone_time = 0 # E.g. .5
+
# Invalidate flag. When 'True', a repaint has been scheduled.
self._invalidated = False
self.on_invalidate = Callback() # Invalidate event.
@@ -291,7 +295,8 @@ class CommandLineInterface(object):
# Call redraw in the eventloop (thread safe).
# Give it low priority. If there is other I/O or CPU intensive
# stuff to handle, give that priority, but max postpone x seconds.
- _max_postpone_until = datetime.datetime.now() + datetime.timedelta(seconds=.5)
+ _max_postpone_until = datetime.datetime.now() + datetime.timedelta(
+ seconds=self.max_render_postpone_time)
self.eventloop.call_from_executor(redraw, _max_postpone_until=_max_postpone_until)
# Depracated alias for 'invalidate'.