[tor-commits] [ooni-probe/develop] Parametrize task timeout and retry count

isis at torproject.org isis at torproject.org
Thu Jun 6 16:41:38 UTC 2013


commit 3dc0795a36db25898bafd4c5f0b25f864781f1a6
Author: Arturo Filastò <art at fuffa.org>
Date:   Thu Apr 11 11:58:29 2013 +0200

    Parametrize task timeout and retry count
---
 ooni/director.py      |    3 ++-
 ooni/managers.py      |   12 ++++++------
 ooni/tasks.py         |    5 +++++
 ooniprobe.conf.sample |   12 ++++++++++++
 4 files changed, 25 insertions(+), 7 deletions(-)

diff --git a/ooni/director.py b/ooni/director.py
index bba5eb3..ec4e461 100644
--- a/ooni/director.py
+++ b/ooni/director.py
@@ -157,7 +157,7 @@ class Director(object):
 
         self.failedMeasurements += 1
         self.failures.append((failure, measurement))
-        return failure
+        return None
 
     def reporterFailed(self, failure, net_test):
         """
@@ -174,6 +174,7 @@ class Director(object):
     def netTestDone(self, result, net_test):
         self.activeNetTests.remove(net_test)
 
+    @defer.inlineCallbacks
     def startNetTest(self, _, net_test_loader, reporters):
         """
         Create the Report for the NetTest and start the report NetTest.
diff --git a/ooni/managers.py b/ooni/managers.py
index 17b430d..d54c169 100644
--- a/ooni/managers.py
+++ b/ooni/managers.py
@@ -1,6 +1,8 @@
 import itertools
+
 from twisted.internet import defer
 from ooni.utils import log
+from ooni import config
 
 def makeIterable(item):
     """
@@ -139,9 +141,8 @@ class MeasurementManager(TaskManager):
     NetTest on the contrary is aware of the typology of measurements that it is
     dispatching as they are logically grouped by test file.
     """
-    # XXX tweak these values
-    retries = 2
-    concurrency = 10
+    retries = config.advanced.measuement_retries
+    concurrency = config.advanced.measurement_concurrency
 
     def succeeded(self, result, measurement):
         log.debug("Successfully performed measurement %s" % measurement)
@@ -151,9 +152,8 @@ class MeasurementManager(TaskManager):
         pass
 
 class ReportEntryManager(TaskManager):
-    # XXX tweak these values
-    retries = 3
-    concurrency = 20
+    retries = config.advanced.reporting_retries
+    concurrency = config.advanced.reporting_concurrency
 
     def succeeded(self, result, task):
         log.debug("Successfully performed report %s" % task)
diff --git a/ooni/tasks.py b/ooni/tasks.py
index c17a5c1..59a908d 100644
--- a/ooni/tasks.py
+++ b/ooni/tasks.py
@@ -1,5 +1,6 @@
 import time
 
+from ooni import config
 from twisted.internet import defer, reactor
 
 class BaseTask(object):
@@ -90,6 +91,8 @@ class TaskWithTimeout(BaseTask):
         return BaseTask.start(self)
 
 class Measurement(TaskWithTimeout):
+    timeout = config.advanced.measurement_timeout
+
     def __init__(self, test_class, test_method, test_input):
         """
         test_class:
@@ -127,6 +130,8 @@ class Measurement(TaskWithTimeout):
         return d
 
 class ReportEntry(TaskWithTimeout):
+    timeout = config.advanced.reporting_timeout
+
     def __init__(self, reporter, measurement):
         self.reporter = reporter
         self.measurement = measurement
diff --git a/ooniprobe.conf.sample b/ooniprobe.conf.sample
index b488216..aeb96c2 100644
--- a/ooniprobe.conf.sample
+++ b/ooniprobe.conf.sample
@@ -33,6 +33,18 @@ advanced:
     # If you do not specify start_tor, you will have to have Tor running and
     # explicitly set the control port and SOCKS port
     start_tor: true
+    # After how many seconds we should give up on a particular measurement
+    measurement_timeout: 30
+    # After how many retries we should give up on a measurement
+    measurement_retry: 2
+    # How many measurments to perform concurrently
+    measurement_concurrency = 100
+    # After how may seconds we should give up reporting
+    reporting_timeout: 30
+    # After how many retries to give up on reporting
+    reporting_retry: 3
+    # How many reports to perform concurrently
+    reporting_concurrency: 20
 tor:
     #socks_port: 9050
     #control_port: 9051





More information about the tor-commits mailing list