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
评论列表
文章目录