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
评论列表
文章目录