Tor subprocess check separate function
This commit is contained in:
parent
4fa43fdf60
commit
d7c1c0d04c
1 changed files with 5 additions and 4 deletions
|
@ -98,8 +98,7 @@ class TorManager(object):
|
||||||
time.sleep(wait * 0.5)
|
time.sleep(wait * 0.5)
|
||||||
self.enabled = True
|
self.enabled = True
|
||||||
if self.connect():
|
if self.connect():
|
||||||
tor_started = self.tor_process.poll() is None
|
if self.isSubprocessRunning():
|
||||||
if tor_started:
|
|
||||||
self.request("TAKEOWNERSHIP") # Shut down Tor client when controll connection closed
|
self.request("TAKEOWNERSHIP") # Shut down Tor client when controll connection closed
|
||||||
break
|
break
|
||||||
# Terminate on exit
|
# Terminate on exit
|
||||||
|
@ -109,11 +108,13 @@ class TorManager(object):
|
||||||
self.enabled = False
|
self.enabled = False
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def isSubprocessRunning(self):
|
||||||
|
return self.tor_process and self.tor_process.pid and self.tor_process.poll() is None
|
||||||
|
|
||||||
def stopTor(self):
|
def stopTor(self):
|
||||||
self.log.debug("Stopping...")
|
self.log.debug("Stopping...")
|
||||||
try:
|
try:
|
||||||
tor_started = self.tor_process.poll() is None
|
if self.isSubprocessRunning():
|
||||||
if tor_started:
|
|
||||||
self.request("SIGNAL SHUTDOWN")
|
self.request("SIGNAL SHUTDOWN")
|
||||||
except Exception, err:
|
except Exception, err:
|
||||||
self.log.error("Error stopping Tor: %s" % err)
|
self.log.error("Error stopping Tor: %s" % err)
|
||||||
|
|
Loading…
Reference in a new issue