当前位置: 首页>>代码示例>>Python>>正文


Python Disco.purge方法代码示例

本文整理汇总了Python中disco.core.Disco.purge方法的典型用法代码示例。如果您正苦于以下问题:Python Disco.purge方法的具体用法?Python Disco.purge怎么用?Python Disco.purge使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在disco.core.Disco的用法示例。


在下文中一共展示了Disco.purge方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: data_gen

# 需要导入模块: from disco.core import Disco [as 别名]
# 或者: from disco.core.Disco import purge [as 别名]
def data_gen(path):
    return "\n".join([path[1:]] * 10)


def fun_map(e, params):
    return [("=" + e, e)]


def fun_reduce(iter, out, params):
    s = 1
    for k, v in iter:
        if k != "=" + v:
            raise Exception("Corrupted key")
        s *= int(v)
    out.add("result", s)


tserver.run_server(data_gen)

inputs = [3, 5, 7, 11, 13, 17, 19, 23, 29, 31]
job = Disco(sys.argv[1]).new_job(
    name="test_simple", input=tserver.makeurl(inputs), map=fun_map, reduce=fun_reduce, nr_reduces=1, sort=False
)

if list(result_iterator(job.wait())) != [("result", ANS)]:
    raise Exception("Invalid answer")

job.purge()
print "ok"
开发者ID:jseppanen,项目名称:disco,代码行数:31,代码来源:test_simple.py

示例2: str

# 需要导入模块: from disco.core import Disco [as 别名]
# 或者: from disco.core.Disco import purge [as 别名]
        try:
            self.target         = str(kwargs.pop('target') or '')
            self.mapfilters     = filter(None, kwargs.pop('mapfilters').split('|'))
            self.reducefilters  = filter(None, kwargs.pop('reducefilters').split('}'))
            self.resultsfilters = filter(None, kwargs.pop('resultsfilters').split(']'))
            job = self.job.run()
        except DiscoError, e:
            return HttpResponseServerError("Failed to run DiscoDB job: %s" % e)

        try:
            results = Results(job.results)
        except DiscoError, e:
            return HttpResponseServerError("DiscoDB job failed: %s" % e)
        finally:
            if os.path.exists(purge_file):
                disco_master.purge(job.name)

        return results.response(request)

class KeysResource(DiscoDBResource):
    job_type    = KeyIterator

class ValuesResource(DiscoDBResource):
    job_type    = ValuesIterator

class ItemsResource(DiscoDBResource):
    job_type    = ItemsIterator

class QueryCollection(Collection):
    allowed_methods = ('GET', 'POST')
开发者ID:christofd,项目名称:disco,代码行数:32,代码来源:models.py

示例3: Disco

# 需要导入模块: from disco.core import Disco [as 别名]
# 或者: from disco.core.Disco import purge [as 别名]
tserver.run_server(data_gen)
disco = Disco(sys.argv[1])

results = disco.new_job(name = "test_chain_0", input = tserver.makeurl([""] * 100),
                map = fun_map, reduce = fun_reduce, nr_reduces = 4,
                sort = False, params = {'suffix': '0'}).wait()

i = 1
while i < 10:
        nresults = disco.new_job(name = "test_chain_%d" % i, input = results,
                map = fun_map, reduce = fun_reduce, nr_reduces = 4,
                map_reader = chain_reader, sort = False,
                params = {'suffix': str(i)}).wait()

        disco.purge(jobname(results[0]))
        results = nresults
        i += 1

for key, value in result_iterator(results):
        if key[:5] not in ani or key[5:] != "0-1-2-3-4-5-6-7-8-9-":
                raise "Corrupted key: %s" % key
        if value != "9":
                raise "Corrupted value: %s" % value

disco.purge(jobname(results[0]))

print "ok"


开发者ID:chenhao7512,项目名称:disco,代码行数:29,代码来源:test_chain.py

示例4: Exception

# 需要导入模块: from disco.core import Disco [as 别名]
# 或者: from disco.core.Disco import purge [as 别名]
                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")






print "ok"
                        
         


开发者ID:chenhao7512,项目名称:disco,代码行数:28,代码来源:test_waitmany.py

示例5: Disco

# 需要导入模块: from disco.core import Disco [as 别名]
# 或者: from disco.core.Disco import purge [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"

开发者ID:chenhao7512,项目名称:disco,代码行数:31,代码来源:test_async.py


注:本文中的disco.core.Disco.purge方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。