Skip to content

Instantly share code, notes, and snippets.

@ixaxaar
Created September 27, 2014 08:54
Show Gist options
  • Save ixaxaar/50ae82469ae0a21dcfb8 to your computer and use it in GitHub Desktop.
Save ixaxaar/50ae82469ae0a21dcfb8 to your computer and use it in GitHub Desktop.
Simple zeromq client that keeps track of dropped messages
#!/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