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

[or-cvs] r17940: {torflow} Fix termination condition. (torflow/trunk/CircuitAnalysis/BuildTimes)



Author: mikeperry
Date: 2009-01-05 19:17:11 -0500 (Mon, 05 Jan 2009)
New Revision: 17940

Modified:
   torflow/trunk/CircuitAnalysis/BuildTimes/buildtimes.py
Log:

Fix termination condition.



Modified: torflow/trunk/CircuitAnalysis/BuildTimes/buildtimes.py
===================================================================
--- torflow/trunk/CircuitAnalysis/BuildTimes/buildtimes.py	2009-01-06 00:11:43 UTC (rev 17939)
+++ torflow/trunk/CircuitAnalysis/BuildTimes/buildtimes.py	2009-01-06 00:17:11 UTC (rev 17940)
@@ -20,31 +20,6 @@
       use_guards=True,
       restrict_guards=True)
 
-class Connection(PathSupport.Connection):
-  """ thread quits when required number of circuits found, otherwise identical"""
-  def __init__(self,s):
-    PathSupport.Connection.__init__(self,s)
-  def _loop(self):
-    while 1:
-      try:
-        isEvent, reply = self._read_reply()
-      except:
-        self._err(sys.exc_info())
-        return
-
-      if isEvent:
-        if self._handler is not None:
-          self._eventQueue.put((time.time(), reply))
-      else:
-        cb = self._queue.get() # atomic..
-        cb(reply)
-
-      if self._handler is not None:
-        if self._handler.done:
-          print 'Finished gathering',self._handler.circ_failed + self._handler.circ_succeeded,'circuits'
-          print self._handler.circ_failed,'failed',self._handler.circ_succeeded,'built'
-          return 
-
 class StatsGatherer(StatsHandler):
   def __init__(self,c, selmgr,basefile_name,nstats):
     StatsHandler.__init__(self,c, selmgr)
@@ -121,7 +96,7 @@
 
   s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
   s.connect((control_host,control_port))
-  c = Connection(s)
+  c = PathSupport.Connection(s)
   c.authenticate()  # also launches thread...
   h = StatsGatherer(c,__selmgr,filename,ncircuits)
   c.set_event_handler(h)
@@ -227,12 +202,13 @@
     h.write_stats(aggfile_name)
     cond.notify()
     cond.release()
-    h.done = True
     print "Wrote stats."
   cond.acquire()
   c._handler.schedule_low_prio(notlambda)
   cond.wait()
   cond.release()
+  c.close()
+  c._thread.join()
   print "Done in main."
 
 def main():