def Thread_Rank(k): """ Method to be done by a thread from the pool""" pack = _args[0] item = Pack() item.name = k item.ratio = ratio(pack, k) return item
def Rankilist(pack): """ Method to execute the algorithm """ cache = Cache() if _options.single: list_app = [] for k in cache: item = Pack() item.name = k.name item.ratio = ratio(pack, k.name) list_app.append(item) return list_app else: _pool = Pool(processes=_MAX_PEERS) result = _pool.map(Thread_Rank, cache._set) return result