- 
                Notifications
    
You must be signed in to change notification settings  - Fork 32
 
♻️Maintenance: improve cancellation error handling #8367
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
♻️Maintenance: improve cancellation error handling #8367
Conversation
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 improves cancellation error handling in the asyncio codebase by replacing manual task cancellation patterns with the centralized cancel_wait_task utility function. The changes follow best practices for asyncio.CancelledError handling to ensure proper cancellation propagation.
- Replaces manual task cancellation with 
cancel_wait_taskutility function - Improves CancelledError handling to properly propagate cancellations when the owner function is being cancelled
 - Updates redis-commander image and fixes a typo
 
Reviewed Changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description | 
|---|---|
| services/web/server/tests/unit/with_dbs/docker-compose-devel.yml | Updates redis-commander image and adds user configuration | 
| services/docker-compose-ops.yml | Updates redis-commander image and adds user configuration | 
| services/director-v2/src/simcore_service_director_v2/modules/dynamic_sidecar/scheduler/_core/_scheduler.py | Replaces manual task cancellation with cancel_wait_task utility | 
| services/director-v2/src/simcore_service_director_v2/modules/dynamic_sidecar/scheduler/_core/_observer.py | Removes unnecessary CancelledError catch-and-reraise pattern | 
| services/catalog/src/simcore_service_catalog/core/background_tasks.py | Removes noqa comment from CancelledError handling | 
| packages/service-library/tests/redis/test_decorators.py | Fixes typo in comment | 
| packages/service-library/src/servicelib/utils.py | Removes ellipsis from function overloads and noqa comment | 
| packages/service-library/src/servicelib/redis/_utils.py | Improves type annotations with ParamSpec and TypeVar | 
| packages/service-library/src/servicelib/redis/_decorators.py | Replaces manual task cancellation with cancel_wait_task utility | 
| packages/service-library/src/servicelib/long_running_tasks/task.py | Adds proper cancellation propagation check | 
| packages/service-library/src/servicelib/fastapi/requests_decorators.py | Replaces manual task cancellation with cancel_wait_task utility | 
| packages/service-library/src/servicelib/deferred_tasks/_worker_tracker.py | Adds proper cancellation propagation check | 
| packages/service-library/src/servicelib/async_utils.py | Replaces manual task cancellation with cancel_wait_task utility | 
| packages/common-library/src/common_library/async_tools.py | Improves cancel_wait_task implementation with better error handling | 
| .github/instructions/python.instructions.md | Restructures instructions file and adds testing guidelines | 
| .github/instructions/node.instructions.md | Creates new Node.js specific instructions file | 
| .github/instructions/general.md.instructions.md | Creates general instructions with typo in filename | 
| .github/instructions/general.instructions.md | Creates general instructions file | 
          Codecov Report❌ Patch coverage is  Additional details and impacted files@@            Coverage Diff             @@
##           master    #8367      +/-   ##
==========================================
- Coverage   87.88%   87.86%   -0.02%     
==========================================
  Files        1945     1945              
  Lines       75620    75626       +6     
  Branches     1316     1321       +5     
==========================================
- Hits        66458    66451       -7     
- Misses       8765     8777      +12     
- Partials      397      398       +1     
 
 Continue to review full report in Codecov by Sentry. 
 🚀 New features to boost your workflow:
  | 
    
          
🧪 CI InsightsHere's what we observed from your CI run for c091814. ❌ Job Failures
 ✅ Passed Jobs With Interesting Signals
  | 
    
88e3c72    to
    110c727      
    Compare
  
    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.
Great job finding this subtly. Thanks a lot for the explanations. I learned a lot
I left some suggestions
Thx
        
          
                packages/service-library/src/servicelib/deferred_tasks/_worker_tracker.py
          
            Show resolved
            Hide resolved
        
              
          
                ...ctor-v2/src/simcore_service_director_v2/modules/dynamic_sidecar/scheduler/_core/_observer.py
          
            Show resolved
            Hide resolved
        
      
          
 | 
    



What do these changes do?
asyncio.CancelledErrorThis should never be consumed anywhere without good reasons --> Always re-raise as any coroutine may be cancelledRelated issue/s
How to test
Dev-ops