Skip to content

⚡ Bolt: Replace synchronous time.sleep with await asyncio.sleep to prevent event loop blocking#9

Open
thirdeyenation wants to merge 1 commit intomainfrom
bolt/asyncio-sleep-optimization-17489271503116669306
Open

⚡ Bolt: Replace synchronous time.sleep with await asyncio.sleep to prevent event loop blocking#9
thirdeyenation wants to merge 1 commit intomainfrom
bolt/asyncio-sleep-optimization-17489271503116669306

Conversation

@thirdeyenation
Copy link
Copy Markdown
Owner

💡 What: Replaced blocking time.sleep() calls inside async def methods with await asyncio.sleep().

🎯 Why: Calling time.sleep() in an async function blocks the entire asyncio event loop. This prevents the server from processing other concurrent requests, background tasks, or WebSocket events while waiting.

📊 Impact: Unblocks the application's async event loop. Particularly during SSH connection retries (up to 5 seconds) and MCP server applications (1 second), the backend can now process other requests concurrently without stalling.

🔬 Measurement: Observe CPU and concurrency metrics when multiple users or events trigger these operations simultaneously. A simple stress test will show the server no longer hangs when hitting these paths.


PR created automatically by Jules for task 17489271503116669306 started by @thirdeyenation

…event event loop blocking

- Replaced time.sleep(1) with await asyncio.sleep(1) in api/mcp_servers_apply.py
- Replaced time.sleep with await asyncio.sleep in plugins/_code_execution/helpers/shell_ssh.py
- Imported asyncio in api/mcp_servers_apply.py
- Updated .jules/bolt.md with learning

Co-authored-by: thirdeyenation <133812267+thirdeyenation@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

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