Last active
July 2, 2017 10:43
-
-
Save FirefoxMetzger/883501b05120069f5fb6eb51ca012942 to your computer and use it in GitHub Desktop.
random poll fixes delivery problem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import zmq | |
context = zmq.Context() | |
address = "inproc://test" | |
#subscriber | |
sub = context.socket(zmq.SUB) | |
sub.bind(address) | |
sub.setsockopt(zmq.SUBSCRIBE, "test") | |
poller = zmq.Poller() | |
poller.register(sub, zmq.POLLIN) | |
#publisher | |
pub = context.socket(zmq.PUB) | |
pub.connect(address) | |
# now the messages are delivered -- updating something internally?? | |
poller.poll(100) | |
#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