Created
April 21, 2011 10:23
-
-
Save commandodev/934112 to your computer and use it in GitHub Desktop.
This file contains 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
class Component(object): | |
def _setup_sockets(self): | |
pub_address = "tcp://whatever..." | |
ext_socket = ctx.socket(zmq.PUB) | |
ext_socket.bind(pub_address) | |
self.internal_addr = "inproc://my_pub" | |
int_socket = ctx.socket(zmq.PULL) | |
int_socket.bind(self.internal_addr) | |
eventlet.spawn_n(self.forward_messages, int_socket, ext_socket) | |
def forward_messages(self, internal, external): | |
while True: | |
external.send(internal.recv()) | |
def create_internal_socket(self): | |
pusher = ctx.socket(zmq.PUSH) | |
pusher.connect(self.internal_addr) | |
return pusher | |
component = Component() | |
eventlet.spawn_n(something_that_wants_to_publish, component.create_internal_socket()) | |
eventlet.spawn_n(something_else_that_wants_to_publish, component.create_internal_socket()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment