diff --git a/deluge/ui/web/js/deluge-all/EventsManager.js b/deluge/ui/web/js/deluge-all/EventsManager.js
index 9a799d5..34e65cd 100644
a
|
b
|
Deluge.EventsManager = Ext.extend(Ext.util.Observable, {
|
91 | 91 | }, |
92 | 92 | |
93 | 93 | onGetEventsSuccess: function(events) { |
94 | | if (!events) return; |
95 | | Ext.each(events, function(event) { |
96 | | var name = event[0], args = event[1]; |
97 | | args.splice(0, 0, name); |
98 | | this.fireEvent.apply(this, args); |
99 | | }, this); |
| 94 | if (events) { |
| 95 | Ext.each(events, function(event) { |
| 96 | var name = event[0], args = event[1]; |
| 97 | args.splice(0, 0, name); |
| 98 | this.fireEvent.apply(this, args); |
| 99 | }, this); |
| 100 | } |
100 | 101 | if (this.running) this.getEvents(); |
101 | 102 | }, |
102 | 103 | |
diff --git a/deluge/ui/web/json_api.py b/deluge/ui/web/json_api.py
index f3ea05e..84c0a5a 100644
a
|
b
|
def get_events(self, listener_id):
|
385 | 385 | |
386 | 386 | # Create a deferred to and check again in 100ms |
387 | 387 | d = Deferred() |
388 | | reactor.callLater(0.1, self._get_events, listener_id, 0, d) |
| 388 | reactor.callLater(0.1, self._get_events, listener_id, time.time(), d) |
389 | 389 | return d |
390 | 390 | |
391 | | def _get_events(self, listener_id, count, d): |
| 391 | def _get_events(self, listener_id, start_time, d): |
392 | 392 | if listener_id in self.__queue: |
393 | 393 | queue = self.__queue[listener_id] |
394 | 394 | del self.__queue[listener_id] |
… |
… |
def _get_events(self, listener_id, count, d):
|
396 | 396 | else: |
397 | 397 | # Prevent this loop going on indefinitely incase a client leaves |
398 | 398 | # the page or disconnects uncleanly. |
399 | | if count >= 3000: |
| 399 | |
| 400 | # timeout after 5 seconds |
| 401 | if time.time() - start_time > 5: |
| 402 | log.warning("_get_events timing out after %f seconds" % (time.time() - start_time,)) |
400 | 403 | d.callback(None) |
401 | 404 | else: |
402 | | reactor.callLater(0.1, self._get_events, listener_id, count + 1, d) |
| 405 | reactor.callLater(0.1, self._get_events, listener_id, start_time, d) |
403 | 406 | |
404 | 407 | def remove_listener(self, listener_id, event): |
405 | 408 | """ |