Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time
- import logging
- from zmq.log import handlers as zmqHandler
- logger = logging.getLogger('myapp')
- logger.setLevel(logging.ERROR)
- zmqH=zmqHandler.PUBHandler('tcp://127.0.0.1:12344')
- logger.addHandler(zmqH)
- for i in range(50):
- logger.error('error test...')
- print "Send error #%s" % (str(i))
- time.sleep(1)
- Send error #0
- Send error #1
- Send error #2
- Send error #3
- Send error #4
- ...
- import time
- import zmq
- def sub_client():
- port = "12344"
- context = zmq.Context()
- socket = context.socket(zmq.SUB)
- socket.connect("tcp://127.0.0.1:%s" % port)
- # Generate 30 entries
- for i in range (30):
- print "Listening to publishers..."
- message = socket.recv()
- print "Received error #%s: %s" % (str(i), message)
- time.sleep(1)
- sub_client()
- Listening to publishers...
- C:>netstat -a -n -o | findstr 12344
- TCP 127.0.0.1:12344 0.0.0.0:0 LISTEN 1336
- TCP 127.0.0.1:12344 127.0.0.1:51937 ESTABLISHED 1336
- TCP 127.0.0.1:51937 127.0.0.1:12344 ESTABLISHED 8624
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement