Closing asyncio task properly#6296
Conversation
There was a problem hiding this comment.
Code Review
This pull request implements proper cleanup for background asyncio tasks by storing task references and explicitly cancelling them during the shutdown of the run_suite method. The review feedback suggests using loop.create_task() instead of asyncio.ensure_future() to ensure consistent event loop usage and avoid potential scope issues. Additionally, it is recommended to refactor the duplicated cancellation logic into a loop for better maintainability and error handling.
c25185e to
0b71a0f
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #6296 +/- ##
==========================================
- Coverage 72.32% 72.32% -0.01%
==========================================
Files 206 206
Lines 23250 23259 +9
==========================================
+ Hits 16816 16822 +6
- Misses 6434 6437 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@richtja @clebergnu could you help me with your review and if possible any hint why doc build is failing? |
harvey0100
left a comment
There was a problem hiding this comment.
This looks good to me -- the cleanup approach makes sense. Storing the task references and cancelling them in order (updater first, then server) before closing is the right way to handle this. I tested the pattern locally, and it cleanly resolves the pending task warnings.
On the loop.create_task() vs ensure_future thing Gemini raised -- I don't think it's a real issue here since loop is always defined by the time the cleanup code runs, but it'd be a nice-to-have for readability if you feel like changing it. Not blocking either way.
For the RTD failure -- don't worry about that, it's just a docs thing that was already fixed on master. A rebase should get you green CI.
Nice fix, thanks for tracking this down from #6282
0b71a0f to
b9eb5cc
Compare
|
@harvey0100, @richtja, any thing else that I can do to help to get this PR moving? |
Prevent
asyncioerror messages forpending tasks destroyedat the end of the execution especially using Avocado's Job API.Error message example:
More information can be found in the conversation #6282