Fix race condition in task cancellation handling#421
Conversation
|
Hi @utksh1, The requested changes have been completed and the CI issues have been resolved. All checks are passing now. Could you please take a look at the PR and let me know if any further changes are needed? If everything looks good, I would appreciate a merge. Thanks for your time! |
utksh1
left a comment
There was a problem hiding this comment.
Thanks for the update. This still needs changes before merge: the PR removes the only database status transition in , so a cancelled task can remain in its previous status after the container/process cleanup. Please keep cancellation authoritative by updating to , setting , broadcasting the status change, and invalidating cached views exactly once. The indentation-only changes lower in the file can also be reverted to keep the PR focused.
|
Clarifying the requested change: keep cancel_task authoritative by updating tasks.status to cancelled, setting completed_at, broadcasting the cancelled status, and invalidating cached views exactly once. The current diff removes that state transition. |
Description
This PR fixes a race condition in task cancellation handling.
Changes Made
cancel_task().asyncio.CancelledErrorpath inexecute_task().Problem Fixed
Previously, both
cancel_task()andexecute_task()could update the task status toCANCELLED, leading to a race condition and inconsistent task state handling.Result
Type of Change
How Has This Been Tested?
CancelledErrorhandler.cancel_task().Checklist