本文整理匯總了Python中disco.core.Disco.results方法的典型用法代碼示例。如果您正苦於以下問題:Python Disco.results方法的具體用法?Python Disco.results怎麽用?Python Disco.results使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類disco.core.Disco
的用法示例。
在下文中一共展示了Disco.results方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: Disco
# 需要導入模塊: from disco.core import Disco [as 別名]
# 或者: from disco.core.Disco import results [as 別名]
return []
tserver.run_server(data_gen)
disco = Disco(sys.argv[1])
jobs = []
for i, m in enumerate([fun_map1, fun_map2, fun_map3, fun_map4]):
jobs.append(disco.new_job(
name = "test_waitmany_%d" % (i + 1),
input = tserver.makeurl([""] * 5),
map = m))
res = []
while jobs:
cont = False
ready, jobs = disco.results(jobs, timeout = 2000)
res += ready
for n, r in res:
if n.startswith("test_waitmany_3"):
if r[0] != "dead":
raise Exception("Invalid job status: %s" % n)
elif r[0] != "ready":
raise Exception("Invalid job status: %s" % n)
disco.purge(n)
if len(res) != 4:
raise Exception("Invalid number of results")
示例2: Disco
# 需要導入模塊: from disco.core import Disco [as 別名]
# 或者: from disco.core.Disco import results [as 別名]
tserver.run_server(data_gen)
disco = Disco(sys.argv[1])
num = sum(x['max_workers'] for x in disco.nodeinfo()['available'])
print >> sys.stderr, num, "slots available"
inputs = tserver.makeurl(range(num * 10))
random.shuffle(inputs)
jobs = []
for i in range(5):
jobs.append(disco.new_job(name = "test_async_%d" % i,
input = inputs[i * (num * 2):(i + 1) * (num * 2)],
map = fun_map, reduce = fun_reduce, nr_reduces = 11,
sort = False))
time.sleep(1)
all = dict(("[%s]" % i, 0) for i in range(num * 10))
while jobs:
ready, jobs = disco.results(jobs)
for name, results in ready:
for k, v in result_iterator(results[1]):
all[k] += 1
disco.purge(name)
for v in all.values():
if v != 10:
raise "Invalid results: %s" % all
print "ok"