Author: damoxc
Revision: 5277
Log:
make use of the DeferredList rather than chaining one request after
another
Diff:
Modified: trunk/deluge/ui/web/json_api.py
===================================================================
--- trunk/deluge/ui/web/json_api.py 2009-05-18 16:26:26 UTC (rev 5276)
+++ trunk/deluge/ui/web/json_api.py 2009-05-18 17:43:29 UTC (rev 5277)
@@ -31,7 +31,7 @@
import tempfile
from types import FunctionType
-from twisted.internet.defer import Deferred
+from twisted.internet.defer import Deferred, DeferredList
from twisted.web import http, resource, server
from deluge import common, component
@@ -357,16 +357,27 @@
def got_stats(stats):
ui_info["stats"] = stats
- d.callback(ui_info)
def got_filters(filters):
ui_info["filters"] = filters
- client.core.get_stats().addCallback(got_stats)
def got_torrents(torrents):
ui_info["torrents"] = torrents
- client.core.get_filter_tree().addCallback(got_filters)
- client.core.get_torrents_status(filter_dict,
keys).addCallback(got_torrents)
+
+ def on_complete(result):
+ d.callback(ui_info)
+
+ d1 = client.core.get_torrents_status(filter_dict, keys)
+ d1.addCallback(got_torrents)
+
+ d2 = client.core.get_filter_tree()
+ d2.addCallback(got_filters)
+
+ d3 = client.core.get_stats()
+ d3.addCallback(got_stats)
+
+ dl = DeferredList([d1, d2, d3], consumeErrors=True)
+ dl.addCallback(on_complete)
return d
def _on_got_files(self, torrent, d):
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---