def receive_loop(self):
"""
This is the receive loop for Banyan messages.
This method may be overwritten to meet the needs
of the application before handling received messages.
"""
while True:
try:
data = self.subscriber.recv_multipart(zmq.NOBLOCK)
if self.numpy:
payload = msgpack.unpackb(data[1], object_hook=m.decode)
self.incoming_message_processing(data[0].decode(), payload)
else:
self.incoming_message_processing(data[0].decode(), umsgpack.unpackb(data[1]))
# if no messages are available, zmq throws this exception
except zmq.error.Again:
try:
time.sleep(self.loop_time)
except KeyboardInterrupt:
self.clean_up()
raise KeyboardInterrupt
评论列表
文章目录