Draft
Conversation
- Replaced `asyncio.gather` with `asyncio.as_completed` in `streamrip/client/qobuz.py` for testing secrets. - Short-circuits remaining tasks to prevent unnecessary network I/O once a valid secret is found. - Cancels pending tasks cleanly using `try...finally` to prevent background leakage. Co-authored-by: davidjuarezdev <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
💡 What:
Replaced
asyncio.gatherwithasyncio.as_completedinQobuzClient._get_valid_secretto test app secrets. Pending tasks are cleanly cancelled as soon as the first valid secret is found.🎯 Why:
The previous implementation used
asyncio.gather(), meaning the application would wait for all secret validation network requests to finish, even if the very first request was successful. This created a slow-tail latency bottleneck.📊 Impact:
Reduces network I/O and latency during Qobuz login. In cases where the first or second secret in the list works, it skips the remaining
N-1requests, avoiding rate limits and making the initial API connection measurably faster.🔬 Measurement:
Run the test suite (
PYTHONPATH=. poetry run pytest tests/test_qobuz_client.py). When a valid secret is located early in the list, the execution time for_get_valid_secretis significantly reduced.PR created automatically by Jules for task 14989891246956479248 started by @davidjuarezdev