dispycos_httpd2.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:pycos 作者: pgiri 项目源码 文件源码
def client_proc(computation, task=None):
    # schedule computation with the scheduler
    if (yield computation.schedule()):
        raise Exception('schedule failed')

    i = 0
    while True:
        cmd = yield task.receive()
        if cmd is None:
            break
        i += 1
        c = C(i)
        c.n = random.uniform(20, 50)
        # unlike in dispycos_client*.py, here 'run_async' is used to run as
        # many tasks as given on servers (i.e., possibly more than one
        # task on a server at any time).
        rtask = yield computation.run_async(compute, c, task)
        if isinstance(rtask, pycos.Task):
            print('  %s: rtask %s created' % (i, rtask))
        else:
            print('  %s: rtask failed: %s' % (i, rtask))

    # unlike in dispycos_httpd1.py, here 'await_async' is not used, so any
    # running async tasks are just terminated.
    yield computation.close()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号