[tor-commits] [ooni-probe/master] Refactor the code of the post processor to work properly.

art at torproject.org art at torproject.org
Tue Oct 29 15:52:16 UTC 2013


commit e89163c608f27cd34cd871b6bcb814a24b65c762
Author: Arturo Filastò <art at fuffa.org>
Date:   Tue Oct 29 16:48:30 2013 +0100

    Refactor the code of the post processor to work properly.
---
 ooni/nettest.py |   21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/ooni/nettest.py b/ooni/nettest.py
index eb68182..560e039 100644
--- a/ooni/nettest.py
+++ b/ooni/nettest.py
@@ -562,25 +562,16 @@ 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()
 



More information about the tor-commits mailing list