Repository navigation
Fix timeout type in has_v2_api using ClientTimeout - #640
Conversation
Refactor API call to include timeout handling.
|
Hi maintainers, could someone please approve and run the GitHub Actions workflows for this PR? The runs expired while awaiting approval, so the checks have not actually run. If the expired runs can’t be approved anymore, could you please trigger new runs? Thanks! |
hoefnageltom
left a comment
There was a problem hiding this comment.
Apologies for the late response.
For the change. I currently don't see your reasoning, asyncio.timeout() works by cancelling the task, which only happens when the event loop gets control back. If something is really blocking the loop with synchronous work, the timeout can't fire either. So this change can't fix "blocking the main event loop".
Updated the API request to use ClientTimeout for better timeout handling.
|
Thanks for the review and feedback, @hoefnageltom! You are completely right on both points:
I've updated the PR to use ClientTimeout(total=5) as suggested and will update the PR description accordingly. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #640 +/- ##
=======================================
Coverage 99.28% 99.28%
=======================================
Files 9 9
Lines 704 704
Branches 70 70
=======================================
Hits 699 699
Misses 2 2
Partials 3 3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
hoefnageltom
left a comment
There was a problem hiding this comment.
Thanks for your contribution! Looks good now
Keep this branch's has_v2_api. It no longer sends the aiohttp request that #640 fixed the timeout of; the TLS connection and the GET /api response use asyncio.wait_for with a 5 second timeout instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Proposed change
Fix timeout type in has_v2_api using ClientTimeout
This PR updates
has_v2_apito passClientTimeout(total=5)instead of anint(timeout=5) towebsession.get().aiohttpexpects aClientTimeoutinstance for thetimeoutparameter. Passing an integer causes an error insideaiohttp(such asAttributeError), which is silently caught by the broadexcept Exception:block and causeshas_v2_apito returnFalse.Using
ClientTimeout(total=5)fixes the timeout handling as intended.Type of change