dispycos_client8.py 文件源码

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

项目:pycos 作者: pgiri 项目源码 文件源码
def compute_task(task=None):
    import time

    client = yield task.receive() # first message is client task

    result = 0
    while True:
        n = yield task.receive()
        if n is None:  # end of requests
            client.send(result)
            break
        # long-running computation (without 'yield') is simulated with
        # 'time.sleep'; during this time client may send messages to this task
        # (which will be received and put in this task's message queue) or this
        # task can send messages to client
        time.sleep(n)
        result += n

# client (local) task runs computations
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号