~ubuntu-branches/debian/jessie/python-eventlet/jessie

« back to all changes in this revision

Viewing changes to examples/zmq_simple.py

  • Committer: Bazaar Package Importer
  • Author(s): Stefano Rivera
  • Date: 2011-06-02 16:18:16 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20110602161816-c888ncsqx70pfvfu
Tags: 0.9.15-1
* New upstream release.
  - Drop all patches, accepted upstream.
* Correct DEP3 headers (first line of Description is the subject)
* Bump Standards-Version to 3.9.2, no changes needed.
* Drop Breaks: ${python:Breaks}, no longer used by dh_python2.
* debian/copyright: Update to DEP5 Format r174.
* Restore doc/modules/zmq.rst and BD on Sphinx 1.0.
* reuseaddr.patch: The logic for deciding whether to use SO_REUSEADDR was
  inverted.
* retry-on-timeout.patch: If an operation times out, try one last time.
  (LP: #771512)

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()