[tor-commits] [doctor/master] Download from authorities in serial

atagar at torproject.org atagar at torproject.org
Sun Oct 11 16:44:38 UTC 2015


commit b2772926bbf9b5f1565b07be96faf053f64bda71
Author: Damian Johnson <atagar at torproject.org>
Date:   Sun Oct 11 09:42:02 2015 -0700

    Download from authorities in serial
    
    Parallel downloads no longer make sense now that we're checking authority
    latency. Attempting to do multiple at once skew our metrics.
---
 consensus_health_checker.py |   17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/consensus_health_checker.py b/consensus_health_checker.py
index d34db57..1a9608d 100755
--- a/consensus_health_checker.py
+++ b/consensus_health_checker.py
@@ -762,7 +762,7 @@ def get_votes():
 
 
 def _get_documents(label, resource):
-  queries, documents, issues = {}, {}, []
+  documents, times_taken, issues = {}, {}, []
 
   for authority in DIRECTORY_AUTHORITIES.values():
     # skip urras, it's having a long outage
@@ -773,25 +773,22 @@ def _get_documents(label, resource):
     if authority.v3ident is None:
       continue  # not a voting authority
 
-    queries[authority.nickname] = downloader.query(
+    query = downloader.query(
       resource,
       endpoints = [(authority.address, authority.dir_port)],
       default_params = False,
       validate = True,
     )
 
-  times_taken = {}
-
-  for authority, query in queries.items():
     try:
       start_time = time.time()
-      documents[authority] = query.run()[0]
-      times_taken[authority] = time.time() - start_time
+      documents[authority.nickname] = query.run()[0]
+      times_taken[authority.nickname] = time.time() - start_time
     except Exception as exc:
       if label == 'vote':
         # try to download the vote via the other authorities
 
-        v3ident = DIRECTORY_AUTHORITIES[authority].v3ident
+        v3ident = DIRECTORY_AUTHORITIES[authority.nickname].v3ident
 
         query = downloader.query(
           '/tor/status-vote/current/%s.z' % v3ident,
@@ -802,10 +799,10 @@ def _get_documents(label, resource):
         query.run(True)
 
         if not query.error:
-          documents[authority] = list(query)[0]
+          documents[authority.nickname] = list(query)[0]
           continue
 
-      issues.append(Issue(Runlevel.ERROR, 'AUTHORITY_UNAVAILABLE', fetch_type = label, authority = authority, url = query.download_url, error = exc, to = [authority]))
+      issues.append(Issue(Runlevel.ERROR, 'AUTHORITY_UNAVAILABLE', fetch_type = label, authority = authority.nickname, url = query.download_url, error = exc, to = [authority.nickname]))
 
   if label == 'consensus':
     median_time = sorted(times_taken.values())[len(times_taken) / 2]



More information about the tor-commits mailing list