In patched_cancel, when a task has been registered but not yet submitted to the backend (uid not in self.running), the else branch executes return fut.original_cancel — returning the bound method object rather than invoking it. The future is therefore never marked as cancelled, the task remains in the ready queue, and it will be submitted and executed normally despite the caller having requested cancellation. This makes future.cancel() a no-op for any task that has not yet reached the backend.
In
patched_cancel, when a task has been registered but not yet submitted to the backend (uid not in self.running), the else branch executes return fut.original_cancel — returning the bound method object rather than invoking it. The future is therefore never marked as cancelled, the task remains in the ready queue, and it will be submitted and executed normally despite the caller having requested cancellation. This makes future.cancel() a no-op for any task that has not yet reached the backend.