[zeromq-dev] can use SUB and PUSH together with device?
timger™
yishenggudou at gmail.com
Tue Jan 29 04:05:48 CET 2013
hi all
I want to recv message from pub broadcast
and then distribute the message to some other process
if I can use SUB and PUSH together with device?
and some code like :
import zmq
import yaml
from time import sleep
conf = yaml.load(open('offline.yaml'))
class Qsuber(object):
def __init__(self):
self.context = zmq.Context()
self.client_id = conf['clientid']
self.sub_connect()
self.push_bind()
def sub_connect(self):
self.socket = self.context.socket(zmq.SUB)
self.socket.setsockopt(zmq.SUBSCRIBE, "")
self.socket.setsockopt(zmq.IDENTITY, self.client_id)
self.socket.connect(conf['zmqsub'])
def push_bind(self):
sleep(0.1)
self.push_socket = self.context.socket(zmq.PUSH)
self.push_socket.setsockopt(zmq.HWM, 0)
self.push_socket.bind(conf['zmqpush'])
def recv(self):
zmq.device(zmq.STREAMER, self.socket, self.push_socket)
if __name__ == "__main__":
main = Qsuber()
main.recv()
timger™
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20130129/268be46e/attachment.htm>
More information about the zeromq-dev
mailing list