mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-03 18:38:31 +08:00
19 lines
571 B
Python
19 lines
571 B
Python
import zmq
|
|
|
|
import zipline.protocol as zp
|
|
|
|
def gen_from_zmq(poller, unframe, namestring):
|
|
"""
|
|
A generator that takes an initialized zmq poller and yields
|
|
messages from the poller until it gets a zp.CONTROL_PROTOCOL.DONE.
|
|
"""
|
|
while True:
|
|
message = poller.recv()
|
|
# Done protocol should now be a message type so that
|
|
# done messages can also have source_ids.
|
|
if message.type == zp.CONTROL_PROTOCOL.DONE:
|
|
yield done_message(message.source_id)
|
|
break
|
|
else:
|
|
yield unframe(message)
|