commit 877a2873a39641d2f0b6e56d8f40ead91c426e03
Author: Leonid Evdokimov <leon(a)darkk.net.ru>
Date: Fri Sep 30 15:02:30 2016 +0300
Fix one of the reasons of stuck scheduler lockfile for RunDeck task, see #612
---
ooni/nettest.py | 18 +++++++++++++-----
ooni/nettests/blocking/web_connectivity.py | 5 ++++-
2 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/ooni/nettest.py b/ooni/nettest.py
index d6784f4..7a2afc8 100644
--- a/ooni/nettest.py
+++ b/ooni/nettest.py
@@ -6,7 +6,7 @@ import sys
from twisted.internet import defer
from twisted.python.filepath import FilePath
from twisted.trial.runner import filenameToModule
-from twisted.python import usage, reflect
+from twisted.python import failure, usage, reflect
from ooni import __version__ as ooniprobe_version, errors
from ooni import otime
@@ -578,6 +578,9 @@ class NetTest(object):
"""
This is a generator that yields measurements and registers the
callbacks for when a measurement is successful or has failed.
+
+ FIXME: If this generator throws exception TaskManager scheduler is
+ irreversibly damaged.
"""
for test_class, test_methods in self.testCases:
@@ -591,11 +594,16 @@ class NetTest(object):
test_instance._setUp()
test_instance.summary = self.summary
for method in test_methods:
+ try:
+ measurement = self.makeMeasurement(
+ test_instance,
+ method,
+ test_input)
+ except Exception:
+ log.exception(failure.Failure())
+ log.err('Failed to run %s %s %s' % (test_instance, method, test_input))
+ continue # it's better to skip single measurement...
log.debug("Running %s %s" % (test_instance, method))
- measurement = self.makeMeasurement(
- test_instance,
- method,
- test_input)
measurements.append(measurement.done)
self.state.taskCreated()
yield measurement
diff --git a/ooni/nettests/blocking/web_connectivity.py b/ooni/nettests/blocking/web_connectivity.py
index d8d539f..1d1b742 100644
--- a/ooni/nettests/blocking/web_connectivity.py
+++ b/ooni/nettests/blocking/web_connectivity.py
@@ -29,6 +29,9 @@ from ooni.common.http_utils import REQUEST_HEADERS
class InvalidControlResponse(Exception):
pass
+class AbsentHostname(Exception):
+ pass
+
class UsageOptions(usage.Options):
optParameters = [
['url', 'u', None, 'Specify a single URL to test'],
@@ -175,7 +178,7 @@ class WebConnectivityTest(httpt.HTTPTest, dnst.DNSTest):
self.hostname = urlparse(self.input).netloc
if not self.hostname:
- raise Exception("Invalid input")
+ raise AbsentHostname('No hostname', self.input)
self.control = {
'tcp_connect': {},