Module: deluge
Branch: master
Commit: f52e3c4aa03e3a1bd72a60a01463d5ce994e4c46

Author: Damien Churchill <[email protected]>
Date:   Sun Oct 10 19:51:50 2010 +0100

add a check to ensure that the events loop doesn't continue indefinitely

---

 deluge/ui/web/json_api.py |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/deluge/ui/web/json_api.py b/deluge/ui/web/json_api.py
index 19a9800..c190f28 100644
--- a/deluge/ui/web/json_api.py
+++ b/deluge/ui/web/json_api.py
@@ -382,16 +382,21 @@ class EventQueue(object):
 
         # Create a deferred to and check again in 100ms
         d = Deferred()
-        reactor.callLater(0.5, self._get_events, listener_id, d)
+        reactor.callLater(0.1, self._get_events, listener_id, 0, d)
         return d
 
-    def _get_events(self, listener_id, d):
+    def _get_events(self, listener_id, count, d):
         if listener_id in self.__queue:
             queue = self.__queue[listener_id]
             del self.__queue[listener_id]
             d.callback(queue)
         else:
-            reactor.callLater(0.1, self._get_events, listener_id, d)
+            # Prevent this loop going on indefinitely incase a client leaves
+            # the page or disconnects uncleanly.
+            if count >= 3000:
+                d.callback(None)
+            else:
+                reactor.callLater(0.1, self._get_events, listener_id, count + 
1, d)
 
     def remove_listener(self, listener_id, event):
         """

-- 
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