- zmsg = Bcast(zsub.recv())
- print("I" if zmsg.is_incoming else "O", zmsg.proto, zmsg.imei)
- for pmod in pmods:
- if pmod.proto_handled(zmsg.proto.startswith):
- msg = pmod.parse_message(zmsg.packet, zmsg.is_incoming)
- print(msg)
+ events = poller.poll(1000)
+ for sk, fl in events:
+ if sk is zraw:
+ while True:
+ try:
+ zmsg = Bcast(zraw.recv(zmq.NOBLOCK))
+ except zmq.Again:
+ break
+ print(
+ "I" if zmsg.is_incoming else "O",
+ zmsg.proto,
+ zmsg.imei,
+ )
+ pmod = common.pmod_for_proto(zmsg.proto)
+ if pmod is not None:
+ msg = pmod.parse_message(
+ zmsg.packet, zmsg.is_incoming
+ )
+ print(msg)
+ if zmsg.is_incoming and hasattr(msg, "rectified"):
+ print("Rectified:", msg.rectified())
+ elif sk is zrep:
+ while True:
+ try:
+ rept = Rept(zrep.recv(zmq.NOBLOCK))
+ except zmq.Again:
+ break
+ print(rept)
+ else:
+ print("what is this socket?!", sk)