<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def confirm_delivery(self, delivery_tag, delivered):
 """Invoked by RabbitMQ when it is confirming delivery via a Basic.Ack :param :param int delivery_tag: The message # being confirmed :param bool delivered: Was the message delivered """

        for offset, msg in self.pending_confirmations():
            if delivery_tag == msg.delivery_tag:
                self.published_messages[offset].future.set_result(delivered)
                return
        for msg in self.published_messages:
            if msg.delivery_tag == delivery_tag and msg.future.done():
                return
        self.logger.warning('Attempted to confirm publish without future: %r',
                            delivery_tag)