本文整理汇总了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"