Skip to content

⚡ Bolt: Optimize Qobuz secret checking#60

Draft
davidjuarezdev wants to merge 1 commit intomainfrom
bolt-optimize-qobuz-secret-check-14989891246956479248
Draft

⚡ Bolt: Optimize Qobuz secret checking#60
davidjuarezdev wants to merge 1 commit intomainfrom
bolt-optimize-qobuz-secret-check-14989891246956479248

Conversation

@davidjuarezdev
Copy link
Copy Markdown
Owner

💡 What:
Replaced asyncio.gather with asyncio.as_completed in QobuzClient._get_valid_secret to 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-1 requests, 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_secret is significantly reduced.


PR created automatically by Jules for task 14989891246956479248 started by @davidjuarezdev

- 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant