[or-cvs] r20507: {torctl} Try to be better about dying if TorCtl is horked. (torctl/trunk/python/TorCtl)
mikeperry at seul.org
mikeperry at seul.org
Tue Sep 8 20:58:42 UTC 2009
Author: mikeperry
Date: 2009-09-08 16:58:42 -0400 (Tue, 08 Sep 2009)
New Revision: 20507
Modified:
torctl/trunk/python/TorCtl/PathSupport.py
torctl/trunk/python/TorCtl/TorCtl.py
Log:
Try to be better about dying if TorCtl is horked.
Modified: torctl/trunk/python/TorCtl/PathSupport.py
===================================================================
--- torctl/trunk/python/TorCtl/PathSupport.py 2009-09-08 20:57:16 UTC (rev 20506)
+++ torctl/trunk/python/TorCtl/PathSupport.py 2009-09-08 20:58:42 UTC (rev 20507)
@@ -1315,12 +1315,14 @@
Schedules an immediate job to be run before the next event is
processed.
"""
+ assert(self.c.is_live())
self.imm_jobs.put(job)
def schedule_low_prio(self, job):
"""
Schedules a job to be run when a non-time critical event arrives.
"""
+ assert(self.c.is_live())
self.low_prio_jobs.put(job)
def reset(self):
@@ -1351,6 +1353,7 @@
processed. Also notifies the selection manager that it needs
to update itself.
"""
+ assert(self.c.is_live())
def notlambda(this):
job(this.selmgr)
this.do_reconfigure = True
Modified: torctl/trunk/python/TorCtl/TorCtl.py
===================================================================
--- torctl/trunk/python/TorCtl/TorCtl.py 2009-09-08 20:57:16 UTC (rev 20506)
+++ torctl/trunk/python/TorCtl/TorCtl.py 2009-09-08 20:58:42 UTC (rev 20507)
@@ -439,15 +439,20 @@
finally:
self._sendLock.release()
+ def is_live(self):
+ """ Returns true iff the connection is alive and healthy"""
+ return self._thread.isAlive() and self._eventThread.isAlive() and not \
+ self._closed
+
def launch_thread(self, daemon=1):
"""Launch a background thread to handle messages from the Tor process."""
assert self._thread is None
- t = threading.Thread(target=self._loop)
+ t = threading.Thread(target=self._loop, name="TorLoop")
if daemon:
t.setDaemon(daemon)
t.start()
self._thread = t
- t = threading.Thread(target=self._eventLoop)
+ t = threading.Thread(target=self._eventLoop, name="EventLoop")
if daemon:
t.setDaemon(daemon)
t.start()
More information about the tor-commits
mailing list