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/heart.py |
initial import of debian package
Diffstat (limited to 'examples/heartbeat/heart.py')
-rw-r--r-- | examples/heartbeat/heart.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/examples/heartbeat/heart.py b/examples/heartbeat/heart.py new file mode 100644 index 0000000..175370e --- /dev/null +++ b/examples/heartbeat/heart.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python +"""This launches an echoing rep socket device, +and runs a blocking numpy action. The rep socket should +remain responsive to pings during this time. Use heartbeater.py to +ping this heart, and see the responsiveness. + +Authors +------- +* MinRK +""" + +import time +import numpy +import zmq +from zmq import devices + +ctx = zmq.Context() + +dev = devices.ThreadDevice(zmq.FORWARDER, zmq.SUB, zmq.DEALER) +dev.setsockopt_in(zmq.SUBSCRIBE, "") +dev.connect_in('tcp://127.0.0.1:5555') +dev.connect_out('tcp://127.0.0.1:5556') +dev.start() + +#wait for connections +time.sleep(1) + +A = numpy.random.random((2**11,2**11)) +print "starting blocking loop" +while True: + tic = time.time() + numpy.dot(A,A.transpose()) + print "blocked for %.3f s"%(time.time()-tic) + |