commit 81c53bbc6107d955731eabe6d41e24c586d07122 Merge: 3b88935 056a24b Author: Arturo Filastò art@fuffa.org Date: Mon Apr 29 18:15:47 2013 +0200
Merge branch 'feature/task_manager' into feature/ui
* feature/task_manager: Make how we keep track of successful reports more robust.
ooni/reporter.py | 12 ++++++------ ooni/tasks.py | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+), 6 deletions(-)
diff --cc ooni/reporter.py index 1095cb1,732d516..5d8f92b --- a/ooni/reporter.py +++ b/ooni/reporter.py @@@ -32,9 -32,9 +32,9 @@@ from ooni import otim from ooni.utils import geodata, pushFilenameStack from ooni.utils.net import BodyReceiver, StringProducer, userAgents
-from ooni import config +from ooni.settings import config
- from ooni.tasks import ReportEntry, TaskTimedOut + from ooni.tasks import ReportEntry, TaskTimedOut, ReportTracker
class ReporterException(Exception): pass diff --cc ooni/tasks.py index f686a9c,428fdbf..35f1236 --- a/ooni/tasks.py +++ b/ooni/tasks.py @@@ -129,7 -129,28 +129,26 @@@ class Measurement(TaskWithTimeout) d = self.netTestMethod() return d
+ class ReportTracker(object): + def __init__(self, reporters): + self.report_completed = 0 + self.reporters = reporters + + def finished(self): + """ + Returns true if all the tasks are done. False if not. + """ + if self.report_completed == len(self.reporters): + return True + return False + + def completed(self): + """ + Called when a new report is completed. + """ + self.report_completed += 1 + class ReportEntry(TaskWithTimeout): - timeout = config.advanced.reporting_timeout - def __init__(self, reporter, measurement): self.reporter = reporter self.measurement = measurement
tor-commits@lists.torproject.org