當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。