channel.py 文件源码

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

项目:pycos 作者: pgiri 项目源码 文件源码
def client_proc(task=None):
    # create channel
    channel = pycos.Channel('sum_prod')
    # create tasks to compute sum and product of numbers sent
    sum_task = pycos.Task(seqsum)
    prod_task = pycos.Task(seqprod)
    # subscribe tasks to channel so they receive messages
    yield channel.subscribe(sum_task)
    yield channel.subscribe(prod_task)
    # send 4 numbers to channel
    for _ in range(4):
        r = random.uniform(0.5, 3)
        channel.send(r)
        print('sent %f' % r)
    # send None to indicate end of data
    channel.send(None)
    yield channel.unsubscribe(sum_task)
    yield channel.unsubscribe(prod_task)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号