roulette.py 文件源码

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

项目:zanph 作者: zanph 项目源码 文件源码
def worker(client,location,query):
    """use the yelp api to find the desired place at a location"""

    #reuse context if it exists, otherwise make a new one
    context = context or zmq.Context.instance()
    service = context.socket(zmq.ROUTER)

    #identify worker
    service.setsockopt(zmq.IDENTITY,b'A')
    service.connect("tcp://localhost:5560")
    while True:
        #send our identity
        service.send('')
        message = service.recv()
        with myLock:
            print "yelp worker got:"
            print message
        if message != "":
            response = queryYelp(client, request)
            service.send(response)
        elif message == "END":
            break
        # else:
        #     with myLock:
        #         print "the server has the wrong identities!"
        #     break
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号