When engine.shutdown() is called, it iterates all components and calls handle_task_cancellation on every non-done future. If a task was already cancelled earlier through the patched_cancel → backend.cancel_task → task_callbacks → handle_task_cancellation path, its future is already done by the time shutdown reaches it, producing the log warning "Attempted to handle an already cancelled task". There is no coordination between the explicit per-task cancel path and the bulk shutdown cancel path to prevent the double-handling.
When engine.shutdown() is called, it iterates all components and calls handle_task_cancellation on every non-done future. If a task was already cancelled earlier through the patched_cancel → backend.cancel_task → task_callbacks → handle_task_cancellation path, its future is already done by the time shutdown reaches it, producing the log warning "Attempted to handle an already cancelled task". There is no coordination between the explicit per-task cancel path and the bulk shutdown cancel path to prevent the double-handling.