'Restore all unacknowledged messages.'

def restore_unacked(self):

    self._flush()
    delivered = self._delivered
    errors = []
    restore = self.channel._restore
    pop_message = delivered.popitem
    while delivered:
        try:
            (_, message) = pop_message()
        except KeyError:
            break
        try:
            restore(message)
        except BaseException as exc:
            errors.append((exc, message))
    delivered.clear()
    return errors
