mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-12 11:20:09 +00:00
use async api for torrent_list(index-page)
This commit is contained in:
parent
9236e9bff2
commit
22c07f8e10
3 changed files with 28 additions and 6 deletions
|
@ -113,8 +113,8 @@ class index:
|
||||||
@deco.auto_refreshed
|
@deco.auto_refreshed
|
||||||
def GET(self, name):
|
def GET(self, name):
|
||||||
vars = web.input(sort=None, order=None ,filter=None , category=None)
|
vars = web.input(sort=None, order=None ,filter=None , category=None)
|
||||||
torrent_list = [get_torrent_status(torrent_id)
|
|
||||||
for torrent_id in ws.proxy.get_session_state()]
|
torrent_list = get_torrent_list()
|
||||||
all_torrents = torrent_list[:]
|
all_torrents = torrent_list[:]
|
||||||
|
|
||||||
#filter-state
|
#filter-state
|
||||||
|
|
|
@ -66,13 +66,16 @@ print torrent_list
|
||||||
start = time.time()
|
start = time.time()
|
||||||
|
|
||||||
torrent_ids = ws.proxy.get_session_state() #Syc-api.
|
torrent_ids = ws.proxy.get_session_state() #Syc-api.
|
||||||
torrent_list = []
|
torrent_dict = {}
|
||||||
for id in torrent_ids:
|
for id in torrent_ids:
|
||||||
async_proxy.get_torrent_status(torrent_list.append, id, [])
|
async_proxy.get_torrent_status(dict_cb(id,torrent_dict), id, [])
|
||||||
async_proxy.force_call(block=True)
|
async_proxy.force_call(block=True)
|
||||||
|
|
||||||
print "Async-list:",time.time() - start
|
print "Async-list:",time.time() - start
|
||||||
print torrent_list
|
print torrent_dict
|
||||||
|
|
||||||
|
|
||||||
|
print sorted(torrent_list[0].keys())
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -150,6 +150,7 @@ def enhance_torrent_status(torrent_id,status):
|
||||||
in: raw torrent_status
|
in: raw torrent_status
|
||||||
out: enhanced torrent_staus
|
out: enhanced torrent_staus
|
||||||
"""
|
"""
|
||||||
|
status = Storage(status)
|
||||||
#add missing values for deluge 0.6:
|
#add missing values for deluge 0.6:
|
||||||
for key in TORRENT_KEYS:
|
for key in TORRENT_KEYS:
|
||||||
if not key in status:
|
if not key in status:
|
||||||
|
@ -221,11 +222,29 @@ def get_torrent_status(torrent_id):
|
||||||
helper method.
|
helper method.
|
||||||
enhance ws.proxy.get_torrent_status with some extra data
|
enhance ws.proxy.get_torrent_status with some extra data
|
||||||
"""
|
"""
|
||||||
status = Storage(ws.proxy.get_torrent_status(torrent_id,TORRENT_KEYS))
|
status = ws.proxy.get_torrent_status(torrent_id,TORRENT_KEYS)
|
||||||
|
|
||||||
return enhance_torrent_status(torrent_id, status)
|
return enhance_torrent_status(torrent_id, status)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def get_torrent_list():
|
||||||
|
"""
|
||||||
|
uses async.
|
||||||
|
"""
|
||||||
|
torrent_ids = ws.proxy.get_session_state() #Syc-api.
|
||||||
|
torrent_dict = {}
|
||||||
|
for id in torrent_ids:
|
||||||
|
ws.async_proxy.get_torrent_status(dict_cb(id,torrent_dict), id, [])
|
||||||
|
ws.async_proxy.force_call(block=True)
|
||||||
|
|
||||||
|
return [enhance_torrent_status(id, status)
|
||||||
|
for id, status in torrent_dict.iteritems()]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get_categories(torrent_list):
|
def get_categories(torrent_list):
|
||||||
trackers = [(torrent['category'] or 'unknown') for torrent in torrent_list]
|
trackers = [(torrent['category'] or 'unknown') for torrent in torrent_list]
|
||||||
categories = {}
|
categories = {}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue