diff options
author | Micah Anderson <micah@riseup.net> | 2014-08-11 16:33:29 -0400 |
---|---|---|
committer | Micah Anderson <micah@riseup.net> | 2014-08-11 16:33:29 -0400 |
commit | cce638a8adf4e045ca5505afea4bda57753c31dd (patch) | |
tree | b5e139d3359ac5b8c7b1afa8acbb1b5b6051c626 /examples/heartbeat/ping.py |
initial import of debian package
Diffstat (limited to 'examples/heartbeat/ping.py')
-rw-r--r-- | examples/heartbeat/ping.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/examples/heartbeat/ping.py b/examples/heartbeat/ping.py new file mode 100644 index 0000000..933a39a --- /dev/null +++ b/examples/heartbeat/ping.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python +"""For use with pong.py + +This script simply pings a process started by pong.py or tspong.py, to +demonstrate that zmq remains responsive while Python blocks. + +Authors +------- +* MinRK +""" + +import time +import numpy +import zmq + +ctx = zmq.Context() + +req = ctx.socket(zmq.REQ) +req.connect('tcp://127.0.0.1:10111') + +#wait for connects +time.sleep(1) +n=0 +while True: + time.sleep(numpy.random.random()) + for i in range(4): + n+=1 + msg = 'ping %i'%n + tic = time.time() + req.send(msg) + resp = req.recv() + print "%s: %.2f ms" % (msg, 1000*(time.time()-tic)) + assert msg == resp + |