Created
October 5, 2011 07:56
-
-
Save michalbachowski/1263904 to your computer and use it in GitHub Desktop.
Test application for PyZQM Issue #141 (https://github.com/zeromq/pyzmq/issues/141).
This file contains hidden or 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 | |
# -*- coding: utf-8 -*- | |
import sys | |
sys.path.append('/home/users/enleth/pyzmq/') | |
import logging | |
import zmq | |
FORMAT = '%(asctime)-15s %(message)s' | |
logging.basicConfig(format=FORMAT) | |
log = logging.getLogger() | |
log.setLevel(logging.DEBUG) | |
def main(): | |
# preapre zmq | |
addr = 'tcp://127.0.0.1:16666' | |
context = zmq.Context() | |
sock = context.socket(zmq.SUB) | |
sock.connect(addr) | |
sock.setsockopt(zmq.SUBSCRIBE, '') | |
while True: | |
route = sock.recv() | |
msg = sock.recv() | |
log.info('route: %s; msg: %s', route, msg) | |
if __name__ == "__main__": | |
main() |
This file contains hidden or 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 | |
# -*- coding: utf-8 -*- | |
import sys | |
sys.path.append('/home/users/enleth/pyzmq/') | |
import logging | |
import zmq | |
import time | |
FORMAT = '%(asctime)-15s %(message)s' | |
logging.basicConfig(format=FORMAT) | |
log = logging.getLogger() | |
log.setLevel(logging.DEBUG) | |
def main(): | |
# preapre zmq | |
addr = 'tcp://127.0.0.1:16666' | |
context = zmq.Context() | |
sock = context.socket(zmq.PUB) | |
sock.setsockopt(zmq.LINGER, 2) | |
sock.setsockopt(zmq.HWM, 0) | |
sock.bind(addr) | |
# send message | |
route = '/my/test' | |
idx = 0 | |
while True: | |
msg = 'test! %u' % idx | |
log.info('Send message to route %s (addr: %s): %s', route, addr, msg) | |
sock.send(route, zmq.SNDMORE) | |
sock.send(msg) | |
idx += 1 | |
time.sleep( 60 * 60 * 4 ) | |
if __name__ == "__main__": | |
main() |
This file contains hidden or 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 | |
# -*- coding: utf-8 -*- | |
import sys | |
sys.path.append('/home/users/enleth/pyzmq/') | |
import logging | |
import zmq | |
FORMAT = '%(asctime)-15s %(message)s' | |
logging.basicConfig(format=FORMAT) | |
log = logging.getLogger() | |
log.setLevel(logging.DEBUG) | |
def main(): | |
# preapre zmq | |
addr = 'tcp://127.0.0.1:16666' | |
context = zmq.Context() | |
sock = context.socket(zmq.SUB) | |
sock.connect(addr) | |
sock.setsockopt(zmq.SUBSCRIBE, '') | |
while True: | |
route = sock.recv() | |
msg = sock.recv() | |
log.info('route: %s; msg: %s', route, msg) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment