[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [nyx/master] Stacktrace when we get a NEWCONSENSUS event



commit 77a41b128940b568dc7a73bd2aabc369c6824f45
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Thu Mar 24 08:41:27 2016 -0700

    Stacktrace when we get a NEWCONSENSUS event
    
    This largely reverts commit df0fc05, but *doesn't* add it back to the
    connection panel. That is to say curses still works but the connection panel
    doesn't.
    
    Doing this since df0fc05 was deceptively broken (task() was never called since
    we weren't a Daemon subclass) *and* getting a NEWCONSENSUS event caused
    stacktraces...
    
      Traceback (most recent call last):
        File "/usr/lib/python2.7/threading.py", line 551, in __bootstrap_inner
          self.run()
        File "/usr/lib/python2.7/threading.py", line 504, in run
          self.__target(*self.__args, **self.__kwargs)
        File "/home/atagar/Desktop/nyx/stem/control.py", line 921, in _event_loop
          self._handle_event(event_message)
        File "/home/atagar/Desktop/nyx/stem/control.py", line 3624, in _handle_event
          listener(event_message)
        File "/home/atagar/Desktop/nyx/nyx/tracker.py", line 815, in _new_consensus_event
          self.update(event.desc)
      AttributeError: 'ConsensusTracker' object has no attribute 'update'
---
 nyx/panel/connection.py |  9 +++++++++
 nyx/tracker.py          | 28 +++++++++++++++-------------
 2 files changed, 24 insertions(+), 13 deletions(-)

diff --git a/nyx/panel/connection.py b/nyx/panel/connection.py
index 952148f..22cda50 100644
--- a/nyx/panel/connection.py
+++ b/nyx/panel/connection.py
@@ -404,6 +404,15 @@ class ConnectionPanel(nyx.panel.Panel, threading.Thread):
 
       self._update()
       self.redraw(True)
+
+      # TODO: The following is needed to show results *but* causes curses to
+      # flicker. For our plans on this see...
+      #
+      #   https://trac.torproject.org/projects/tor/ticket/18547#comment:1
+
+      # 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 662f965..a772ff9 100644
--- a/nyx/tracker.py
+++ b/nyx/tracker.py
@@ -29,6 +29,7 @@ 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
@@ -814,24 +815,25 @@ class ConsensusTracker(object):
   def _new_consensus_event(self, event):
     self.update(event.desc)
 
-  def _task(self, process_pid, process_name):
+  def update(self, router_status_entries):
     """
-    If this is our first run then populate our cache.
+    Updates our cache with the given router status entries.
+
+    :param list router_status_entries: router status entries to populate our cache with
     """
 
-    if not self._fingerprint_cache:
-      new_fingerprint_cache = {}
-      new_address_cache = {}
-      new_nickname_cache = {}
+    new_fingerprint_cache = {}
+    new_address_cache = {}
+    new_nickname_cache = {}
 
-      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'
+    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'
 
-      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):
     """



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits