'Publish a CommandFailedEvent to all command listeners.
:Parameters:
- `duration`: The command duration as a datetime.timedelta.
- `failure`: The server reply document or failure description
document.
- `command_name`: The command name.
- `request_id`: The request id for this operation.
- `connection_id`: The address (host, port) of the server this
command was sent to.
- `op_id`: The (optional) operation id for this operation.'

def publish_command_failure(self, duration, failure, command_name, request_id, connection_id, op_id=None):

    if (op_id is None):
        op_id = request_id
    event = CommandFailedEvent(duration, failure, command_name, request_id, connection_id, op_id)
    for subscriber in self.__command_listeners:
        try:
            subscriber.failed(event)
        except Exception:
            _handle_exception()
