[tor-commits] [nyx/master] Fix curses flickering

atagar at torproject.org atagar at torproject.org
Mon Mar 14 17:08:54 UTC 2016


commit df0fc05f405e3fbffe0acb28d276e5ef27f5af3e
Author: Damian Johnson <atagar at torproject.org>
Date:   Mon Mar 14 10:09:05 2016 -0700

    Fix curses flickering
    
    Commit 6f91af2 fixed an issue where we froze when viewing the connections page
    after first starting, but at the expense of making our whole interface flicker.
    This is most noticeable when pressing 'm' to browse the menu.
    
    Can't say I'm entirely clear what's up. The connection panel had its own thread
    outside the draw loop so I wouldn't expect it to cause this sort of disruption,
    though due to the GIL that's of course possible. Oh well - doing this in the
    tracker is just better all around...
    
      * no more curses flickering
      * connection panel can be viewed right away
      * code's more elegant
---
 nyx/panel/connection.py |  9 ---------
 nyx/tracker.py          | 28 +++++++++++++---------------
 2 files changed, 13 insertions(+), 24 deletions(-)

diff --git a/nyx/panel/connection.py b/nyx/panel/connection.py
index 7e19a02..e3124d9 100644
--- a/nyx/panel/connection.py
+++ b/nyx/panel/connection.py
@@ -407,15 +407,6 @@ class ConnectionPanel(nyx.panel.Panel, threading.Thread):
 
       self._update()
       self.redraw(True)
-
-      # If this is our first run then fill in our fingerprint tracker. This
-      # requires fetching all the router status entries which takes a few
-      # seconds, so best done when we're finished with the rest of the first
-      # iteration to hide the lag.
-
-      if last_ran == -1:
-        nyx.tracker.get_consensus_tracker().update(tor_controller().get_network_statuses([]))
-
       last_ran = time.time()
 
   def get_help(self):
diff --git a/nyx/tracker.py b/nyx/tracker.py
index a772ff9..662f965 100644
--- a/nyx/tracker.py
+++ b/nyx/tracker.py
@@ -29,7 +29,6 @@ Background tasks for gathering information about the tor process.
     +- stop - stops further work by the daemon
 
   ConsensusTracker - performant lookups for consensus related information
-    |- update - updates the consensus information we're based on
     |- get_relay_nickname - provides the nickname for a given relay
     |- get_relay_fingerprints - provides relays running at a location
     +- get_relay_address - provides the address a relay is running at
@@ -815,25 +814,24 @@ class ConsensusTracker(object):
   def _new_consensus_event(self, event):
     self.update(event.desc)
 
-  def update(self, router_status_entries):
+  def _task(self, process_pid, process_name):
     """
-    Updates our cache with the given router status entries.
-
-    :param list router_status_entries: router status entries to populate our cache with
+    If this is our first run then populate our cache.
     """
 
-    new_fingerprint_cache = {}
-    new_address_cache = {}
-    new_nickname_cache = {}
+    if not self._fingerprint_cache:
+      new_fingerprint_cache = {}
+      new_address_cache = {}
+      new_nickname_cache = {}
 
-    for desc in router_status_entries:
-      new_fingerprint_cache.setdefault(desc.address, []).append((desc.or_port, desc.fingerprint))
-      new_address_cache[desc.fingerprint] = (desc.address, desc.or_port)
-      new_nickname_cache[desc.fingerprint] = desc.nickname if desc.nickname else 'Unnamed'
+      for desc in tor_controller().get_network_statuses([]):
+        new_fingerprint_cache.setdefault(desc.address, []).append((desc.or_port, desc.fingerprint))
+        new_address_cache[desc.fingerprint] = (desc.address, desc.or_port)
+        new_nickname_cache[desc.fingerprint] = desc.nickname if desc.nickname else 'Unnamed'
 
-    self._fingerprint_cache = new_fingerprint_cache
-    self._address_cache = new_address_cache
-    self._nickname_cache = new_nickname_cache
+      self._fingerprint_cache = new_fingerprint_cache
+      self._address_cache = new_address_cache
+      self._nickname_cache = new_nickname_cache
 
   def get_relay_nickname(self, fingerprint):
     """



More information about the tor-commits mailing list