def __init__(self, amqp_host, exchange, stdin=sys.stdin, stdout=sys.stdout, **kwargs): self.amqp_host = amqp_host self.exchange = exchange self.stdin = stdin self.stdout = stdout self.rpc = self._get_rpc() self.supervisor_id = self.rpc.supervisor.getIdentification() self.channel = connect_to_amqp(amqp_host, exchange, **kwargs)
def listen(keys, qname='procs', exchange=EXCHANGE): print keys keys = keys.split(',') ch = connect_to_amqp() qname, _, _ = ch.queue_declare(qname, auto_delete=True, durable=False) for key in keys: ch.queue_bind(qname, exchange, key) ch.basic_consume(qname, callback=amqp_callback) while ch.callbacks: try: ch.wait() except (KeyboardInterrupt, SystemExit): sys.exit()
def __init__(self, amqp_host, amqp_exchange=EXCHANGE, **kwargs): self.amqp_host = amqp_host self.amqp_exchange = amqp_exchange self.channel = connect_to_amqp(amqp_host, amqp_exchange, **kwargs) self.message_queue = Queue() self.listener = spawn_n(self.subscribe)