def sender(): global chan, topic, seq, local_ip for n in xrange(1000): msg = TopicMessage(topic=topic, sender=local_ip) msg.payload = {b'seq': seq} chan.send(msg) seq += 1 return
zmq_ctx = zmq.Context() sout = zmq_ctx.socket(zmq.PUB) ## sout.setsockopt(zmq.HWM, 20000) ## sout.setsockopt(zmq.RATE, 50000000) sout.connect(url) ts = TopicSerializer() ## ts.dumps = msgpack.dumps ## ts.loads = msgpack.loads ts.dumps = marshal.dumps ts.loads = marshal.loads ts.multipart = True while True: msg = TopicMessage(topic=topic, sender=local_ip) msg.payload = {b'seq': seq} seq += 1 data = ts.serialize(msg) pprint(data) sout.send_multipart(data) if (seq % 1) == 0: ## gc.collect() time.sleep(0.333) ## gc.collect() ## time.sleep(1.0) ## gc.collect() except KeyboardInterrupt: pass print