Created
September 27, 2014 08:54
-
-
Save ixaxaar/50ae82469ae0a21dcfb8 to your computer and use it in GitHub Desktop.
Simple zeromq client that keeps track of dropped messages
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import zmq | |
import time | |
def client(): | |
context = zmq.Context() | |
socket = context.socket(zmq.PULL) | |
socket.setsockopt(zmq.LINGER, -1) | |
socket.connect('tcp://127.0.0.1:8888') | |
ctr = 0 | |
prev = 0 | |
while 1: | |
ctr = int(socket.recv()) | |
if ctr % 10000 == 0: print ctr | |
if ctr - prev != 1: | |
print "lost messages " + str(ctr - prev - 1) | |
prev = ctr | |
time.sleep(0.0001) | |
if __name__ == "__main__": | |
client() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment