aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorQingping Hou <dave2008713@gmail.com>2014-02-17 23:01:07 -0500
committerQingping Hou <dave2008713@gmail.com>2014-02-17 23:57:32 -0500
commit93c06edf52eacb90f5950815dcb234ee13324703 (patch)
tree99c31c1077b34cf8de910e9afb44a4d362b7ceed /lib
parent90ae6fee472779322c3b0d6c32ada590e829089e (diff)
downloadchutney-93c06edf52eacb90f5950815dcb234ee13324703.tar
chutney-93c06edf52eacb90f5950815dcb234ee13324703.tar.gz
remove stale lock file for crashed Tor
Diffstat (limited to 'lib')
-rw-r--r--lib/chutney/TorNet.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/chutney/TorNet.py b/lib/chutney/TorNet.py
index 77e768a..74ec087 100644
--- a/lib/chutney/TorNet.py
+++ b/lib/chutney/TorNet.py
@@ -466,6 +466,14 @@ class LocalNodeController(NodeController):
return
os.kill(pid, sig)
+ def cleanup_lockfile(self):
+ lf = self._env['lockfile']
+ if self.isRunning() or (not os.path.exists(lf)):
+ return
+ print 'Removing stale lock file for {0} ...'.format(
+ self._env['nick'])
+ os.remove(lf)
+
@@ -547,6 +555,9 @@ class TorEnviron(chutney.Templating.Environ):
def _get_torrc_template_path(self, my):
return [ os.path.join(my['chutney_dir'], 'torrc_templates') ]
+ def _get_lockfile(self, my):
+ return os.path.join(self['dir'], 'lock')
+
class Network(object):
"""A network of Tor nodes, plus functions to manipulate them
@@ -624,6 +635,9 @@ class Network(object):
for n in xrange(15):
time.sleep(1)
if all(not c.isRunning() for c in controllers):
+ # check for stale lock file when Tor crashes
+ for c in controllers:
+ c.cleanup_lockfile()
return
sys.stdout.write(".")
sys.stdout.flush()