Advertisement
Guest User

Untitled

a guest
Apr 24th, 2012
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.32 KB | None | 0 0
  1. # Load Normal ZMQ
  2. import zmq
  3.  
  4. # Connect To Control Socket
  5. networkContext = zmq.Context(1)
  6. workDispatcherSocket = networkContext.socket(zmq.REQ)
  7. workDispatcherSocket.connect("tcp://%s:%s" % ('127.0.0.1','9988'))
  8.  
  9. try:
  10.    
  11.     workDispatcherSocket.recv(flags=zmq.NOBLOCK)
  12.    
  13. except zmq.ZMQError as e:
  14.    
  15.         # Capture Socket Not Ready Error , If Not EAGAIN Log..
  16.         if e.errno != zmq.EFSM:
  17.             print "Normal ZMQ - EFSM Raised"
  18.         elif e.errno != zmq.EAGAIN:
  19.             print "Normal ZMQ - EAGAIN Raised"
  20.         else:
  21.             print "Normal ZMQ - Other Raised %s " % e.errno
  22.  
  23. #
  24. # Now Green ZMQ
  25. #
  26.  
  27. workDispatcherSocket.close(linger=0)
  28. networkContext.term()
  29. del zmq
  30.  
  31. # Green Zmq
  32. import zmq.green as zmq
  33.  
  34. # Connect To Control Socket
  35. networkContext = zmq.Context(1)
  36. workDispatcherSocket = networkContext.socket(zmq.REQ)
  37. workDispatcherSocket.connect("tcp://%s:%s" % ('127.0.0.1','9988'))
  38.  
  39. try:
  40.    
  41.     workDispatcherSocket.recv(flags=zmq.NOBLOCK)
  42.    
  43. except zmq.ZMQError as e:
  44.    
  45.         # Capture Socket Not Ready Error , If Not EAGAIN Log..
  46.         if e.errno != zmq.EFSM:
  47.             print "Green ZMQ - EFSM Raised"
  48.         elif e.errno != zmq.EAGAIN:
  49.             print "Green ZMQ - EAGAIN Raised"
  50.         else:
  51.             print "Green ZMQ - Other Raised %s " % e.errno
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement