~ubuntu-branches/ubuntu/utopic/python-eventlet/utopic

« back to all changes in this revision

Viewing changes to examples/zmq_simple.py

  • Committer: Bazaar Package Importer
  • Author(s): Soren Hansen
  • Date: 2011-05-17 11:52:34 UTC
  • mfrom: (1.1.4 upstream) (4.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20110517115234-fcxnkhmr7kcvesdz
Tags: 0.9.15-0ubuntu1
* New upstream release.
  - Drop wrap-greenpipe.patch: Included upstream.
  - Drop disable-psycopg-patcher-test.patch: Included upstream.
* Merge packaging changes from Debian.
* Disable zmq (tests do not pass).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from eventlet.green import zmq
 
2
import eventlet
 
3
 
 
4
CTX = zmq.Context(1)
 
5
 
 
6
def bob_client(ctx, count):
 
7
    print "STARTING BOB"
 
8
    bob = zmq.Socket(CTX, zmq.REQ)
 
9
    bob.connect("ipc:///tmp/test")
 
10
 
 
11
    for i in range(0, count):
 
12
        print "BOB SENDING"
 
13
        bob.send("HI")
 
14
        print "BOB GOT:", bob.recv()
 
15
 
 
16
def alice_server(ctx, count):
 
17
    print "STARTING ALICE"
 
18
    alice = zmq.Socket(CTX, zmq.REP)
 
19
    alice.bind("ipc:///tmp/test")
 
20
 
 
21
    print "ALICE READY"
 
22
    for i in range(0, count):
 
23
        print "ALICE GOT:", alice.recv()
 
24
        print "ALIC SENDING"
 
25
        alice.send("HI BACK")
 
26
 
 
27
alice = eventlet.spawn(alice_server, CTX, 10)
 
28
bob = eventlet.spawn(bob_client, CTX, 10)
 
29
 
 
30
bob.wait()
 
31
alice.wait()