Repository navigation
Replace time.sleep with asyncio.sleep for async calls - #7503
Open
MaddipatlaChetan24 wants to merge 1 commit into
Open
MaddipatlaChetan24 wants to merge 1 commit into
MaddipatlaChetan24 wants to merge 1 commit into
Conversation
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.
Link to Issue or Description of Change
Problem:
PlaywrightComputer.current_state()andhighlight_mouse()use blockingtime.sleep()calls insideasyncmethods. Since this file runs directly on the ADK agent's asyncio event loop (no thread/executor offload), eachtime.sleep()freezes the entire event loop — not just the current coroutine — for its duration (0.5s per screenshot, 1s per mouse highlight), stalling any other concurrent work on the loop (e.g. the agent's live session streaming).Solution: Replace both
time.sleep()calls withawait asyncio.sleep(), which yields control back to the event loop instead of blocking it.Testing Plan
Unit Tests:
No existing unit tests cover this file.
Manual End-to-End (E2E) Tests:
Reproduced the stall with a minimal harness: a heartbeat() coroutine ticking every 0.1s run concurrently with a coroutine calling time.sleep(1) — the heartbeat showed a full 1-second gap between ticks. Re-ran with await asyncio.sleep(1) instead — ticks stayed evenly spaced at ~0.1s with no gap. Also verified the changed file parses correctly (ast.parse).
Checklist