Skip to content

⚡ Bolt: Short-circuit Qobuz app secret validation#57

Draft
davidjuarezdev wants to merge 1 commit intomainfrom
bolt-qobuz-secret-short-circuit-4619569938749258132
Draft

⚡ Bolt: Short-circuit Qobuz app secret validation#57
davidjuarezdev wants to merge 1 commit intomainfrom
bolt-qobuz-secret-short-circuit-4619569938749258132

Conversation

@davidjuarezdev
Copy link
Copy Markdown
Owner

💡 What: Modified _get_valid_secret in streamrip/client/qobuz.py to use asyncio.as_completed and cancel remaining background requests once a valid secret is found, instead of using asyncio.gather.
🎯 Why: To prevent "tail latency". When testing multiple secrets, asyncio.gather waits for all requests to finish (even invalid ones that might be slow or timeout) before returning the valid secret. Using as_completed allows us to short-circuit the execution and return the fast, valid response immediately.
📊 Impact: Speeds up the Qobuz login and secret-fetching phase. Instead of being blocked by the slowest invalid request (potentially taking several seconds), it now completes as fast as the quickest valid response.
🔬 Measurement: Verify by executing PYTHONPATH=. poetry run pytest tests/test_qobuz_client.py and noting the faster execution time for login tasks, as well as observing the clean termination of the asyncio loop without background leaks.


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

Optimize `_get_valid_secret` to return the first successful valid
secret and cancel remaining tasks, preventing tail-latency.

Co-authored-by: davidjuarezdev <230496599+davidjuarezdev@users.noreply.github.com>
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