Ticket #2038: fix-chrome-17.patch

File fix-chrome-17.patch, 2.3 KB (added by bobbyrward, 13 years ago)

Changes get_events to timeout after 5 seconds

  • deluge/ui/web/js/deluge-all/EventsManager.js

    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, {  
    9191    },
    9292
    9393    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        }
    100101        if (this.running) this.getEvents();
    101102    },
    102103
  • deluge/ui/web/json_api.py

    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):  
    385385
    386386        # Create a deferred to and check again in 100ms
    387387        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)
    389389        return d
    390390
    391     def _get_events(self, listener_id, count, d):
     391    def _get_events(self, listener_id, start_time, d):
    392392        if listener_id in self.__queue:
    393393            queue = self.__queue[listener_id]
    394394            del self.__queue[listener_id]
    def _get_events(self, listener_id, count, d):  
    396396        else:
    397397            # Prevent this loop going on indefinitely incase a client leaves
    398398            # 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,))
    400403                d.callback(None)
    401404            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)
    403406
    404407    def remove_listener(self, listener_id, event):
    405408        """