diff options
author | Micah Anderson <micah@riseup.net> | 2014-11-11 11:53:55 -0500 |
---|---|---|
committer | Micah Anderson <micah@riseup.net> | 2014-11-11 11:53:55 -0500 |
commit | 7d5c3dcd969161322deed6c43f8a6a3cb92c3369 (patch) | |
tree | 109b05c88c7252d7609ef324d62ef9dd7f06123f /examples/eventloop/echostream.py | |
parent | 44be832c5708baadd146cb954befbc3dcad8d463 (diff) |
upgrade to 14.4.1upstream/14.4.1
Diffstat (limited to 'examples/eventloop/echostream.py')
-rw-r--r-- | examples/eventloop/echostream.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/examples/eventloop/echostream.py b/examples/eventloop/echostream.py new file mode 100644 index 0000000..04c1532 --- /dev/null +++ b/examples/eventloop/echostream.py @@ -0,0 +1,24 @@ +#!/usr/bin/env python +"""Adapted echo.py to put the send in the event loop using a ZMQStream. + +Authors +------- +* MinRK +""" + +import zmq +from zmq.eventloop import ioloop, zmqstream +loop = ioloop.IOLoop.instance() + +ctx = zmq.Context() +s = ctx.socket(zmq.REP) +s.bind('tcp://127.0.0.1:5555') +stream = zmqstream.ZMQStream(s, loop) + +def echo(msg): + print " ".join(msg) + stream.send_multipart(msg) + +stream.on_recv(echo) + +loop.start()
\ No newline at end of file |