X-Git-Url: https://review.fuel-infra.org/gitweb?a=blobdiff_plain;f=eventlet%2Fexamples%2Fzmq_simple.py;fp=eventlet%2Fexamples%2Fzmq_simple.py;h=6f5f11e39f46c64789c21779506d7b5ded116f3d;hb=376ff3bfe7071cc0793184a378c4e74508fb0d97;hp=0000000000000000000000000000000000000000;hpb=70992db4bef26426213a8eae488be377cdd655ae;p=packages%2Ftrusty%2Fpython-eventlet.git diff --git a/eventlet/examples/zmq_simple.py b/eventlet/examples/zmq_simple.py new file mode 100644 index 0000000..6f5f11e --- /dev/null +++ b/eventlet/examples/zmq_simple.py @@ -0,0 +1,33 @@ +from eventlet.green import zmq +import eventlet + +CTX = zmq.Context(1) + + +def bob_client(ctx, count): + print("STARTING BOB") + bob = zmq.Socket(CTX, zmq.REQ) + bob.connect("ipc:///tmp/test") + + for i in range(0, count): + print("BOB SENDING") + bob.send("HI") + print("BOB GOT:", bob.recv()) + + +def alice_server(ctx, count): + print("STARTING ALICE") + alice = zmq.Socket(CTX, zmq.REP) + alice.bind("ipc:///tmp/test") + + print("ALICE READY") + for i in range(0, count): + print("ALICE GOT:", alice.recv()) + print("ALIC SENDING") + alice.send("HI BACK") + +alice = eventlet.spawn(alice_server, CTX, 10) +bob = eventlet.spawn(bob_client, CTX, 10) + +bob.wait() +alice.wait()