commit 8a63d6d03cb2d50f45d63a8bf6023c19f66a02c5 Author: aagbsn aagbsn@extc.org Date: Fri Feb 15 17:53:55 2013 +0100
Cancel tasks on timeout
Deferred.cancel() swallows AlreadyCalled exceptions. --- ooni/tasks.py | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/ooni/tasks.py b/ooni/tasks.py index a73ce11..c17a5c1 100644 --- a/ooni/tasks.py +++ b/ooni/tasks.py @@ -62,13 +62,15 @@ class TaskTimedOut(Exception): pass
class TaskWithTimeout(BaseTask): - timeout = 5 + timeout = 30 # So that we can test the callLater calls clock = reactor
def _timedOut(self): """Internal method for handling timeout failure""" - self._running.errback(TaskTimedOut) + if not self._running.called: + self._running.cancel() + self._failed(TaskTimedOut)
def _cancelTimer(self): #import pdb; pdb.set_trace()
tor-commits@lists.torproject.org