SHOW:
|
|
- or go back to the newest paste.
| 1 | import zmq | |
| 2 | ctx = zmq.Context.instance() | |
| 3 | socket = ctx.socket(zmq.REQ) | |
| 4 | socket.REQ_RELAXED = 1 | |
| 5 | socket.SNDTIMEO = 4000 | |
| 6 | socket.connect("tcp://127.0.0.1:12345")
| |
| 7 | print(socket.send("blah")) #Returns None immediately
| |
| 8 | - | print(socket.send("blah")) #Waits 4 seconds and throws EAGAIN |
| 8 | + | try: |
| 9 | print(socket.send("blah")) #Waits 4 seconds and throws EAGAIN
| |
| 10 | except zmq.Again: | |
| 11 | print("Got Again")
| |
| 12 | socket.connect("tcp://127.0.0.1:12345")
| |
| 13 | print(socket.send("blah")) #Returns None immediately
| |
| 14 | try: | |
| 15 | print(socket.send("blah")) #Waits 4 seconds and throws EAGAIN
| |
| 16 | except zmq.Again: | |
| 17 | print("Got Again") |