- 
                Notifications
    
You must be signed in to change notification settings  - Fork 32
 
🐛 Ensure consistent Celery task cancellation #8354
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🐛 Ensure consistent Celery task cancellation #8354
Conversation
          Codecov Report❌ Patch coverage is  Additional details and impacted files@@            Coverage Diff             @@
##           master    #8354      +/-   ##
==========================================
- Coverage   87.81%   87.66%   -0.15%     
==========================================
  Files        1945     1529     -416     
  Lines       75557    63323   -12234     
  Branches     1313      686     -627     
==========================================
- Hits        66348    55512   -10836     
+ Misses       8813     7569    -1244     
+ Partials      396      242     -154     
 
 Continue to review full report in Codecov by Sentry. 
 🚀 New features to boost your workflow:
  | 
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes the Celery task cancellation mechanism by removing the dependency on AbortableTask and implementing a new cancellation approach based on task existence checking.
Key Changes:
- Replaced 
AbortableTaskwith standard CeleryTaskacross the codebase - Implemented task cancellation through task removal rather than abortion
 - Added 
exists_taskmethod to check task existence for cancellation monitoring 
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description | 
|---|---|
packages/service-library/src/servicelib/celery/task_manager.py | 
Added exists_task method to the TaskManager protocol | 
packages/service-library/src/servicelib/celery/models.py | 
Moved TASK_FINAL_STATES constant to module level and updated references | 
packages/celery-library/tests/unit/test_tasks.py | 
Updated test function signature to use standard Task instead of AbortableTask | 
packages/celery-library/src/celery_library/task_manager.py | 
Refactored cancellation logic to use task removal and added exists_task implementation | 
packages/celery-library/src/celery_library/task.py | 
Replaced AbortableTask usage with standard Task and updated cancellation monitoring | 
          
🧪 CI InsightsHere's what we observed from your CI run for 5d0bca6. ✅ Passed Jobs With Interesting Signals
  | 
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thx. please check the exception handlers issue.
        
          
                services/api-server/src/simcore_service_api_server/api/routes/tasks.py
              
                Outdated
          
            Show resolved
            Hide resolved
        
              
          
                services/api-server/src/simcore_service_api_server/api/routes/tasks.py
              
                Outdated
          
            Show resolved
            Hide resolved
        
      There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thx!
        
          
                services/api-server/src/simcore_service_api_server/exceptions/handlers/__init__.py
              
                Outdated
          
            Show resolved
            Hide resolved
        
              
          
                services/api-server/src/simcore_service_api_server/exceptions/handlers/__init__.py
              
                Outdated
          
            Show resolved
            Hide resolved
        
      
          
 | 
    



What do these changes do?
This PR fixes the Celery task cancellation mechanism by removing the dependency on
AbortableTaskand implementing a new cancellation approach based on task existence checking.Key Changes:
AbortableTaskwith standard CeleryTaskacross the codebaseexists_taskmethod to check task existence for cancellation monitoringNote
We get rid of
AbortableTask, due to inconsistencies when used in combination oftask_track_started=Trueoption.See: celery/celery#2335
Related issue/s
How to test
Dev-ops
No changes