[tor-commits] [ooni-probe/master] modify resetTimer and cancelTimer to avoid alreadyCancelled exception

art at torproject.org art at torproject.org
Fri Nov 20 14:41:59 UTC 2015


commit 2a385f9292755fe66fea4f6952c02c033ff715c6
Author: juga0 <juga>
Date:   Sat Sep 19 19:24:10 2015 +0000

    modify resetTimer and cancelTimer to avoid alreadyCancelled exception
---
 ooni/templates/process.py |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/ooni/templates/process.py b/ooni/templates/process.py
index 3bbd8f6..4939441 100644
--- a/ooni/templates/process.py
+++ b/ooni/templates/process.py
@@ -19,6 +19,7 @@ class ProcessDirector(protocol.ProcessProtocol):
     def cancelTimer(self):
         if self.timeout and self.timer:
             self.timer.cancel()
+            self.timer = None
 
     def close(self, reason=None):
         self.reason = reason
@@ -26,7 +27,7 @@ class ProcessDirector(protocol.ProcessProtocol):
 
     def resetTimer(self):
         if self.timeout is not None:
-            if self.timer is not None:
+            if self.timer is not None and self.timer.active():
                 self.timer.cancel()
             self.timer = reactor.callLater(self.timeout,
                                            self.close,





More information about the tor-commits mailing list