commit 458ee9fc3b7efa542a9c343b078c65c5698f7021 Author: aagbsn aagbsn@extc.org Date: Fri Nov 22 12:49:14 2013 +0000
Revert "Refactor the code of the post processor to work properly."
This reverts commit e89163c608f27cd34cd871b6bcb814a24b65c762.
Reason: this commit breaks writing reports. --- ooni/nettest.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/ooni/nettest.py b/ooni/nettest.py index 9304f2b..f008654 100644 --- a/ooni/nettest.py +++ b/ooni/nettest.py @@ -563,16 +563,25 @@ class NetTest(object): measurement = self.makeMeasurement(klass, method, input) measurements.append(measurement.done) self.state.taskCreated() - measurement.done.addCallback(klass.postProcessor) - if self.report: - @measurement.done.addCallback - def cb(*a): - self.report.write(measurement) - measurement.done.addBoth(self.doneReport) yield measurement
# When the measurement.done callbacks have all fired # call the postProcessor before writing the report + if self.report: + post = defer.DeferredList(measurements) + + # Call the postProcessor, which must return a single report + # or a deferred + post.addCallback(klass.postProcessor) + def noPostProcessor(failure, report): + failure.trap(NoPostProcessor) + return report + post.addErrback(noPostProcessor, klass.report) + post.addCallback(self.report.write) + + if self.report and self.director: + #ghetto hax to keep NetTestState counts are accurate + [post.addBoth(self.doneReport) for _ in measurements]
self.state.allTasksScheduled()
tor-commits@lists.torproject.org