docs: make wait_for_callback async - #3466
Closed
saquibsaifee wants to merge 3 commits into
Closed
Conversation
What: Modified CallbackServer.wait_for_callback in mcp_simple_auth_client/main.py to be an async function, utilizing await asyncio.sleep(0.1) instead of the blocking time.sleep(0.1). The call in callback_handler was also updated to await this execution. Why: The previous implementation used the blocking time.sleep, which stalled the asyncio event loop and delayed other background coroutines running concurrently, making the application unresponsive during the waiting period. Measured Improvement: Baseline: Max event loop delay was measured at ~0.910s when simulating a 1s wait. After fix: Event loop remained fully responsive (Max delay 0.000s) during the wait period.
What: Modified CallbackServer.wait_for_callback in mcp_simple_auth_client/main.py to be an async function, utilizing await asyncio.sleep(0.1) instead of the blocking time.sleep(0.1). The call in callback_handler was also updated to await this execution. Why: The previous implementation used the blocking time.sleep, which stalled the asyncio event loop and delayed other background coroutines running concurrently, making the application unresponsive during the waiting period. Measured Improvement: Baseline: Max event loop delay was measured at ~0.910s when simulating a 1s wait. After fix: Event loop remained fully responsive (Max delay 0.000s) during the wait period.
What: Modified CallbackServer.wait_for_callback in mcp_simple_auth_client/main.py to be an async function, utilizing await asyncio.sleep(0.1) instead of the blocking time.sleep(0.1). The call in callback_handler was also updated to await this execution. Why: The previous implementation used the blocking time.sleep, which stalled the asyncio event loop and delayed other background coroutines running concurrently, making the application unresponsive during the waiting period. Measured Improvement: Baseline: Max event loop delay was measured at ~0.910s when simulating a 1s wait. After fix: Event loop remained fully responsive (Max delay 0.000s) during the wait period.
Contributor
|
This PR has been closed automatically. This repo only keeps pull requests open when they come from a maintainer, or from a contributor a maintainer has assigned to the linked issue, and this PR doesn't link an open issue yet.
You're welcome to keep pushing commits here (just avoid force-pushing, since GitHub can't reopen a rewritten branch), but that on its own won't get the PR reviewed or the issue assigned, and realistically most auto-closed PRs stay closed. There's no need to open a new PR either way. CONTRIBUTING.md has the full reasoning, but in short:
Maintainers: reopen, remove |
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.
While this is an example client, keeping its event loop responsive is important for correctness and for demonstrating best practices when using asyncio.