measurement.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:bwscanner 作者: TheTorProject 项目源码 文件源码
def run_scan(self):
        all_done = defer.Deferred()
        if self.scan_continuous:
            all_done.addCallback(lambda ign: self.run_scan())
        self.circuits = TwoHop(self.state,
            partitions=self.partitions, this_partition=self.this_partition)

        def scan_over_next_circuit():
            try:
                self.fetch(self.circuits.next())
            except StopIteration:
                # All circuit measurement tasks have been setup. Now wait for
                # all tasks to complete before writing results, and firing
                # the all_done deferred.
                task_list = defer.DeferredList(self.tasks)
                task_list.addCallback(lambda _: self.result_sink.end_flush())
                task_list.chainDeferred(all_done)
            else:
                # We have circuits left, schedule scan on the next circuit
                self.clock.callLater(self.circuit_launch_delay,
                                     scan_over_next_circuit)

        # Scan the first circuit
        self.clock.callLater(0, scan_over_next_circuit)
        return all_done
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号