Skip to content

Commit

Permalink
Fix one of the reasons of stuck scheduler lockfile for RunDeck task, …
Browse files Browse the repository at this point in the history
…see #612
  • Loading branch information
darkk authored and hellais committed Oct 11, 2016
1 parent 2dab7a2 commit 877a287
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
18 changes: 13 additions & 5 deletions ooni/nettest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
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
Expand Down Expand Up @@ -578,6 +578,9 @@ def generateMeasurements(self):
"""
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:
Expand All @@ -591,11 +594,16 @@ def generateMeasurements(self):
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
Expand Down
5 changes: 4 additions & 1 deletion ooni/nettests/blocking/web_connectivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
class InvalidControlResponse(Exception):
pass

class AbsentHostname(Exception):
pass

class UsageOptions(usage.Options):
optParameters = [
['url', 'u', None, 'Specify a single URL to test'],
Expand Down Expand Up @@ -175,7 +178,7 @@ def setUp(self):

self.hostname = urlparse(self.input).netloc
if not self.hostname:
raise Exception("Invalid input")
raise AbsentHostname('No hostname', self.input)

self.control = {
'tcp_connect': {},
Expand Down

0 comments on commit 877a287

Please sign in to comment.