*,
    callbacks: None | TaskStateChangeCallback | list[TaskStateChangeCallback],
    context: Context,
) -> None:
    """
    Run callback after task finishes.
    :param callbacks: callbacks to run
    :param context: callbacks context
    :meta private:
    """
    if callbacks:
        callbacks = callbacks if isinstance(callbacks, list) else [callbacks]
        for callback in callbacks:
            try:
                callback(context)
            except Exception:
                callback_name = qualname(callback).split(".")[-1]
                log.exception("Error when executing %s callback", callback_name)  
def _log_state(*, task_instance: TaskInstance | TaskInstancePydantic, lead_msg: str = "") -> None: