Module: deluge
Branch: sessionproxy
Commit: 606b623d731a8bd8f0028431d387e264e09bef77

Author: Andrew Resch <[email protected]>
Date:   Sat Mar 20 19:12:28 2010 -0700

AlertManager will now cancel all pending delayedCalls prior to stopping.

---

 deluge/core/alertmanager.py |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/deluge/core/alertmanager.py b/deluge/core/alertmanager.py
index ef4ff67..b55a994 100644
--- a/deluge/core/alertmanager.py
+++ b/deluge/core/alertmanager.py
@@ -66,9 +66,17 @@ class AlertManager(component.Component):
         # handlers is a dictionary of lists {"alert_type": [handler1,h2,..]}
         self.handlers = {}
 
+        self.delayed_calls = []
+
     def update(self):
+        self.delayed_calls = [dc for dc in self.delayed_calls if dc.active()]
         self.handle_alerts()
 
+    def stop(self):
+        for dc in self.delayed_calls:
+            dc.cancel()
+        self.delayed_calls = []
+
     def register_handler(self, alert_type, handler):
         """
         Registers a function that will be called when 'alert_type' is pop'd
@@ -117,7 +125,7 @@ class AlertManager(component.Component):
             if alert_type in self.handlers:
                 for handler in self.handlers[alert_type]:
                     if not wait:
-                        reactor.callLater(0, handler, alert)
+                        self.delayed_calls.append(reactor.callLater(0, 
handler, alert))
                     else:
                         handler(alert)
 

-- 
You received this message because you are subscribed to the Google Groups 
"deluge-commit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/deluge-commit?hl=en.

Reply via email to