Skip to content
Snippets Groups Projects
Commit 2c8c116d authored by Damian Johnson's avatar Damian Johnson
Browse files

Consolidate redraws if unable to draw for a while

When the menu's open for a while we block the graph panel from redrawing
itself, causing events to accumilate. Then when the menu's closed we perform
a flurry of updates which makes the graph appear to catch up in fast forward.

Instead, if a panel is unable to draw itself after a second it gives up the
redraw attempt. This way when the menu's closed we perform just a single redraw
that catches us up.

Caught thanks to Guinness on tor-relays@.
parent b29878e7
No related branches found
No related tags found
No related merge requests found
......@@ -92,6 +92,7 @@ import functools
import os
import re
import threading
import time
import stem.util.conf
import stem.util.enum
......@@ -709,7 +710,15 @@ def draw(func, left = 0, top = 0, width = None, height = None, background = None
:returns: :class:`~nyx.curses.Dimension` for the space we drew within
"""
with CURSES_LOCK:
start = time.time()
while not CURSES_LOCK.acquire(False):
if (time.time() - start) > 1:
return # if we've been blocked from drawing for a full second then abort
time.sleep(0.05)
try:
if HALT_ACTIVITY:
return
......@@ -738,6 +747,8 @@ def draw(func, left = 0, top = 0, width = None, height = None, background = None
curses_subwindow.refresh()
return subwindow_dimensions
finally:
CURSES_LOCK.release()
class _Subwindow(object):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment