'Callback function which is called when an item is read.'

def _read_item(self, item, queue, callback):

    d = queue.get()
    d.addCallback(self._read_item, queue, callback)
    d.addErrback(self._read_item_err)
    (channel, deliver, props, msg) = item
    log.msg(('%s    (%s):    %s' % (deliver.exchange, deliver.routing_key, repr(msg))), system='Pika:<=')
    d = defer.maybeDeferred(callback, item)
    d.addCallbacks((lambda _: channel.basic_ack(deliver.delivery_tag)), (lambda _: channel.basic_nack(deliver.delivery_tag)))
