Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class queueReader:
- def __init__(self, conn, exchange, basename):
- self._conn = conn
- self._basename = basename
- self._exchange = exchange
- def associateConnection(self, connection):
- log.msg("associating")
- self._conn = connection
- self.openChannel()
- def openChannel(self):
- def _openChann(channel):
- log.msg("Opening channel")
- t = channel.channel_open().addCallback( lambda _: channel.queue_declare(queue=self._basename + "_out", durable=True, exclusive=False, auto_delete=False)).addErrback(log.err)
- t.addCallback(lambda _: channel.basic_consume(queue=self._basename + '_out', no_ack=True, consumer_tag=self._basename +"_out_consumer"))
- self._chan = channel
- t.addCallback(_createQueue)
- return channel
- def _createQueue(ignored):
- log.msg("Creating queue")
- self._queue = self._conn.queue(self._basename + "_out_consumer")
- self._queue.addCallback(lambda _: log.msg(self._queue.get()))
- self._chan = self._conn.channel(BOT_PROTOCOL_LIST.index(self._basename)+2)
- return self._chan.addCallback(_openChann)
- def getDeferred(self):
- pass
- def clientConnectionLost(self, connector, reason):
- print reason
- def clientConnectionFailed(self, connector, reason):
- print reason
Add Comment
Please, Sign In to add comment