commit 359b99d1399761d2a6cf24cd66b21041cd51e4ab Author: aagbsn aagbsn@extc.org Date: Mon Nov 18 14:41:36 2013 +0000
Add measurement result to measurement object.
Simplify callback chain by adding the measurement result to the measurement object. --- ooni/director.py | 4 +++- ooni/managers.py | 2 +- ooni/nettest.py | 5 +++-- 3 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/ooni/director.py b/ooni/director.py index 628b812..7a81815 100644 --- a/ooni/director.py +++ b/ooni/director.py @@ -174,10 +174,11 @@ class Director(object): def measurementStarted(self, measurement): self.totalMeasurements += 1
- def measurementSucceeded(self, measurement): + def measurementSucceeded(self, result, measurement): log.msg("Successfully completed measurement: %s" % measurement) self.totalMeasurementRuntime += measurement.runtime self.successfulMeasurements += 1 + measurement.result = result return measurement
def measurementFailed(self, failure, measurement): @@ -186,6 +187,7 @@ class Director(object):
self.failedMeasurements += 1 self.failures.append((failure, measurement)) + measurement.result = failure return measurement
def reporterFailed(self, failure, net_test): diff --git a/ooni/managers.py b/ooni/managers.py index a229044..b6e87e4 100644 --- a/ooni/managers.py +++ b/ooni/managers.py @@ -80,7 +80,7 @@ class TaskManager(object): self._fillSlots()
# Fires the done deferred when the task has completed - task.done.callback(task) + task.done.callback(result) self.succeeded(result, task)
@property diff --git a/ooni/nettest.py b/ooni/nettest.py index 2982f4d..b6dac29 100644 --- a/ooni/nettest.py +++ b/ooni/nettest.py @@ -535,9 +535,10 @@ class NetTest(object): measurement.netTest = self
if self.director: - measurement.done.addCallback(self.director.measurementSucceeded) + measurement.done.addCallback(self.director.measurementSucceeded, + measurement) measurement.done.addErrback(self.director.measurementFailed, - measurement) + measurement) return measurement
@defer.inlineCallbacks
tor-commits@lists.torproject.org