[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] r18664: {torctl} Log keyerror exception.. Still not clear why it happens, but (torctl/trunk/python/TorCtl)
Author: mikeperry
Date: 2009-02-21 07:43:29 -0500 (Sat, 21 Feb 2009)
New Revision: 18664
Modified:
torctl/trunk/python/TorCtl/StatsSupport.py
torctl/trunk/python/TorCtl/TorCtl.py
Log:
Log keyerror exception.. Still not clear why it happens, but
at least now we should log instead of dying.
Modified: torctl/trunk/python/TorCtl/StatsSupport.py
===================================================================
--- torctl/trunk/python/TorCtl/StatsSupport.py 2009-02-21 10:37:51 UTC (rev 18663)
+++ torctl/trunk/python/TorCtl/StatsSupport.py 2009-02-21 12:43:29 UTC (rev 18664)
@@ -41,6 +41,7 @@
import copy
import time
import math
+import traceback
import TorUtil, PathSupport, TorCtl
from TorUtil import *
@@ -523,9 +524,13 @@
elif c.status == "EXTENDED":
delta = c.arrived_at - self.circuits[c.circ_id].last_extended_at
r_ext = c.path[-1]
- if r_ext[0] != '$': r_ext = self.name_to_key[r_ext]
- self.routers[r_ext[1:]].total_extend_time += delta
- self.routers[r_ext[1:]].total_extended += 1
+ try:
+ if r_ext[0] != '$': r_ext = self.name_to_key[r_ext]
+ self.routers[r_ext[1:]].total_extend_time += delta
+ self.routers[r_ext[1:]].total_extended += 1
+ except KeyError, e:
+ traceback.print_exc()
+ plog("WARN", "No key "+str(e)+" for "+r_ext+" in dict:"+str(self.name_to_key))
elif c.status == "FAILED":
for r in self.circuits[c.circ_id].path: r.circ_chosen += 1
Modified: torctl/trunk/python/TorCtl/TorCtl.py
===================================================================
--- torctl/trunk/python/TorCtl/TorCtl.py 2009-02-21 10:37:51 UTC (rev 18663)
+++ torctl/trunk/python/TorCtl/TorCtl.py 2009-02-21 12:43:29 UTC (rev 18664)
@@ -1083,7 +1083,6 @@
self.name_to_key = {}
self.RouterClass = RouterClass
self.update_consensus()
- self._read_routers(self.consensus.values())
def _read_routers(self, nslist):
old_idhexes = sets.Set(self.routers.keys())
@@ -1129,6 +1128,7 @@
def update_consensus(self):
self._update_consensus(self.c.get_network_status())
+ self._read_routers(self.consensus.values())
def new_consensus_event(self, n):
self._update_consensus(n.nslist)