-
Notifications
You must be signed in to change notification settings - Fork 32
🎨 ♻️ Improves task cancellation with new cancel_and_wait utility
#7956
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
🎨 ♻️ Improves task cancellation with new cancel_and_wait utility
#7956
Conversation
cancel_and_wait tool
cancel_and_wait toolcancel_and_wait utility
|
@mergify queue |
🟠 Waiting for conditions to match
|
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
Introduces a new cancel_and_wait utility to standardize asyncio task cancellation across services and replaces ad-hoc cancel/await logic. Also adds unit tests for the new utility.
- Added
cancel_and_waitimplementation incommon_library.async_tools - Updated multiple cleanup functions in payment and garbage-collector modules to use
cancel_and_wait - Added tests for
cancel_and_waitintest_async_tools.py
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| services/web/server/src/simcore_service_webserver/payments/_tasks.py | Replaced manual cancel/await with cancel_and_wait |
| services/web/server/src/simcore_service_webserver/garbage_collector/_tasks_users.py | Ditto for user GC task |
| services/web/server/src/simcore_service_webserver/garbage_collector/_tasks_trash.py | Ditto for trash GC task |
| services/web/server/src/simcore_service_webserver/garbage_collector/_tasks_core.py | Ditto for core GC background task |
| services/web/server/src/simcore_service_webserver/garbage_collector/_tasks_api_keys.py | Ditto for API-key GC task |
| packages/common-library/src/common_library/async_tools.py | New cancel_and_wait function added |
| packages/common-library/tests/test_async_tools.py | Tests for cancel_and_wait added |
Comments suppressed due to low confidence (1)
packages/common-library/tests/test_async_tools.py:6
- The tests reference
asyncio(e.g.,asyncio.sleep,asyncio.create_task) but don't import it. Addimport asyncioat the top of the file.
from common_library.async_tools import cancel_and_wait, make_async, maybe_await
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #7956 +/- ##
==========================================
- Coverage 87.83% 87.62% -0.21%
==========================================
Files 1849 1451 -398
Lines 71343 59996 -11347
Branches 1250 705 -545
==========================================
- Hits 62663 52572 -10091
+ Misses 8318 7189 -1129
+ Partials 362 235 -127
Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
sanderegg
left a comment
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.
Please replace the other one called cancel_wait_task thanks!
cancel_and_wait utilitycancel_and_wait utility
cancel_and_wait utilitycancel_and_wait utility
sanderegg
left a comment
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
bisgaard-itis
left a comment
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
70c353e to
d502eaa
Compare
cfe5917 to
cc1ffe1
Compare
… garbage collector tasks
7400200 to
b715ab0
Compare
|
@mergify queue |
🟠 Waiting for conditions to match
|
|



What do these changes do?
This pull request introduces a new utility function,
cancel_and_wait, to simplify and standardize the cancellation and cleanup of asyncio tasks. It also updates existing code to use this function in various services and adds corresponding unit tests to ensure its correctness._cleanup_ctx_funin multiple service files to usecancel_and_waitfor task cancellation to solvesonarcloudwarnings:services/web/server/src/simcore_service_webserver/garbage_collector/_tasks_api_keys.pyservices/web/server/src/simcore_service_webserver/garbage_collector/_tasks_core.pyservices/web/server/src/simcore_service_webserver/garbage_collector/_tasks_trash.pyservices/web/server/src/simcore_service_webserver/garbage_collector/_tasks_users.pyservices/web/server/src/simcore_service_webserver/payments/_tasks.pyservicelib.cancel_wait_taskRelated issue/s
How to test
Dev-ops
NOne