Skip to content

Instantly share code, notes, and snippets.

@FirefoxMetzger FirefoxMetzger/
Last active Jul 2, 2017

What would you like to do?
random poll fixes delivery problem
import zmq
context = zmq.Context()
address = "inproc://test"
sub = context.socket(zmq.SUB)
sub.setsockopt(zmq.SUBSCRIBE, "test")
poller = zmq.Poller()
poller.register(sub, zmq.POLLIN)
pub = context.socket(zmq.PUB)
# now the messages are delivered -- updating something internally??
#send some messages
pub.send("test 123")
pub.send("test 345")
pub.send("foo 23")
pub.send("test hello")
# retrieve
has_next = True
while has_next:
has_next = False
sock = dict(poller.poll(100))
if sub in sock:
has_next = True
msg = sub.recv()
print msg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.