Skip to content

Instantly share code, notes, and snippets.

@espeed
Created October 19, 2011 02:49
Show Gist options
  • Save espeed/1297366 to your computer and use it in GitHub Desktop.
Save espeed/1297366 to your computer and use it in GitHub Desktop.
Python ZeroMQ Device Blocking -- Why?
# 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