find-tor: record more detailed timings

This commit is contained in:
Brian Warner 2016-03-03 15:07:05 -08:00
parent 12c4c51fd8
commit 9630ab9aae
2 changed files with 6 additions and 0 deletions

View File

@ -41,7 +41,9 @@ class TwistedReceiver(BlockingReceiver):
def go(self): def go(self):
tor_manager = None tor_manager = None
if self.args.tor: if self.args.tor:
_start = self.args.timing.add_event("import TorManager")
from ..twisted.tor_manager import TorManager from ..twisted.tor_manager import TorManager
self.args.timing.finish_event(_start)
tor_manager = TorManager(reactor, timing=self.args.timing) tor_manager = TorManager(reactor, timing=self.args.timing)
# For now, block everything until Tor has started. Soon: launch # For now, block everything until Tor has started. Soon: launch
# tor in parallel with everything else, make sure the TorManager # tor in parallel with everything else, make sure the TorManager

View File

@ -79,6 +79,7 @@ class TorManager:
_start_find = self._timing.add_event("find tor") _start_find = self._timing.add_event("find tor")
# try port 9051, then try /var/run/tor/control . Throws on failure. # try port 9051, then try /var/run/tor/control . Throws on failure.
state = None state = None
_start_tcp = self._timing.add_event("tor localhost")
try: try:
connection = (self._reactor, "127.0.0.1", self._tor_control_port) connection = (self._reactor, "127.0.0.1", self._tor_control_port)
state = yield txtorcon.build_tor_connection(connection) state = yield txtorcon.build_tor_connection(connection)
@ -86,8 +87,10 @@ class TorManager:
except ConnectError: except ConnectError:
print("unable to reach Tor on %d" % self._tor_control_port) print("unable to reach Tor on %d" % self._tor_control_port)
pass pass
self._timing.finish_event(_start_tcp)
if not state: if not state:
_start_unix = self._timing.add_event("tor unix")
try: try:
connection = (self._reactor, "/var/run/tor/control") connection = (self._reactor, "/var/run/tor/control")
state = yield txtorcon.build_tor_connection(connection) state = yield txtorcon.build_tor_connection(connection)
@ -95,6 +98,7 @@ class TorManager:
except (ValueError, ConnectError): except (ValueError, ConnectError):
print("unable to reach Tor on /var/run/tor/control") print("unable to reach Tor on /var/run/tor/control")
pass pass
self._timing.finish_event(_start_unix)
if state: if state:
print("connected to pre-existing Tor process") print("connected to pre-existing Tor process")