dispycos_ssh_ec2.py 文件源码

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

项目:pycos 作者: pgiri 项目源码 文件源码
def client_proc(computation, njobs, task=None):
    # schedule computation with the scheduler; scheduler accepts one computation
    # at a time, so if scheduler is shared, the computation is queued until it
    # is done with already scheduled computations
    if (yield computation.schedule()):
        raise Exception('Could not schedule computation')

    # pair EC2 node with this client with:
    yield pycos.Pycos().peer(pycos.Location('54.204.242.185', 51347))
    # if multiple nodes are used, 'broadcast' option can be used to pair with
    # all nodes with just one statement as:
    # yield pycos.Pycos().peer(pycos.Location('54.204.242.185', 51347), broadcast=True)

    # execute n jobs (tasks) and get their results. Note that number of
    # jobs created can be more than number of server processes available; the
    # scheduler will use as many processes as necessary/available, running one
    # job at a server process
    args = [random.uniform(3, 10) for _ in range(njobs)]
    results = yield computation.run_results(compute, args)
    for result in results:
        print('result: %s' % result)

    yield computation.close()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号