Created
October 19, 2011 02:49
-
-
Save espeed/1297366 to your computer and use it in GitHub Desktop.
Python ZeroMQ Device Blocking -- Why?
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
# SOLVED, thanks to Chuck Remes -- I was using zmq.QUEUE instead of zmq.STREAMER | |
pd = ProcessDevice(zmq.STREAMER, zmq.PUSH, zmq.PULL) | |
pd.bind_in("tcp://127.0.0.1:6000") | |
pd.bind_out("tcp://127.0.0.1:6001") | |
pd.start() | |
def client(): | |
context = zmq.Context() | |
socket = context.socket(zmq.PUSH) | |
socket.connect("tcp://127.0.0.1:6000") | |
for i in xrange(0,10): | |
print "inside client loop" | |
socket.send('sending message #%s' % i) | |
def worker(): | |
context = zmq.Context() | |
socket = context.socket(zmq.PULL) | |
socket.connect("tcp://127.0.0.1:6001") | |
for i in xrange(0,10): | |
print "inside worker loop" | |
message = socket.recv() | |
print "got message! %s" % message | |
client() | |
worker() | |
pd.join() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment