def do_fetch(self):
time_start = time.time()
path = self.random_path()
agent = OnionRoutedAgent(reactor, path=path, state=self.tor)
url = "http://127.0.0.1:{}".format(self.port)
request = yield agent.request("GET", url)
body = yield readBody(request)
assert len(body) == self.fetch_size
circ = [c for c in self.tor.circuits.values() if c.path == path][0]
assert isinstance(circ, Circuit)
# XXX: Wait for circuit to close, then I think we can be sure that
# the BW events have been emitted.
yield circ.close(ifUnused=True)
defer.returnValue({'duration': time.time() - time_start, 'circ': circ})
评论列表
文章目录