from zorro import Hub, zmq
def replier(preference,*other_multipart_args):
if preference == b'binary':
return b'hello'
elif preference == b'unicode':
return 'hello' # same as above, encoded in 'utf-8'
elif preference == b'tuple':
return 'hello', 'world' # two parts will be sent
else:
# exeption will be logged, but reply is not sent
# so you must timeout on the other side
# other requests will be ok (we use ZMQ_XREP actually)
raise ValueError(preference)
hub = Hub()
@hub.run
def main():
sock = zmq.rep_socket(replier)
sock.connect('tcp://somewhere')