From b9cfb48d17e43812ef400fde6f34c410b7cdb4ed Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sun, 24 May 2026 08:47:45 +0000 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=20Bolt:=20Replace=20blocking=20time.s?= =?UTF-8?q?leep=20with=20await=20asyncio.sleep?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: thirdeyenation <133812267+thirdeyenation@users.noreply.github.com> --- .jules/bolt.md | 3 +++ api/mcp_servers_apply.py | 3 ++- plugins/_code_execution/helpers/shell_ssh.py | 4 ++-- 3 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 .jules/bolt.md diff --git a/.jules/bolt.md b/.jules/bolt.md new file mode 100644 index 0000000000..9e39ee68e1 --- /dev/null +++ b/.jules/bolt.md @@ -0,0 +1,3 @@ +## 2025-01-31 - [Async Event Loop Blocking] +**Learning:** Using synchronous `time.sleep()` inside `async` Python functions blocks the event loop, degrading concurrency and performance for all other asynchronous operations. +**Action:** Always replace `time.sleep()` with non-blocking `await asyncio.sleep()` in any `async def` functions. diff --git a/api/mcp_servers_apply.py b/api/mcp_servers_apply.py index 7ea5275db5..75c390b529 100644 --- a/api/mcp_servers_apply.py +++ b/api/mcp_servers_apply.py @@ -1,3 +1,4 @@ +import asyncio import time from helpers.api import ApiHandler, Request, Response @@ -15,7 +16,7 @@ async def process(self, input: dict[Any, Any], request: Request) -> dict[Any, An set_settings_delta({"mcp_servers": "[]"}) # to force reinitialization set_settings_delta({"mcp_servers": mcp_servers}) - time.sleep(1) # wait at least a second + await asyncio.sleep(1) # wait at least a second # MCPConfig.wait_for_lock() # wait until config lock is released status = MCPConfig.get_instance().get_servers_status() return {"success": True, "status": status} diff --git a/plugins/_code_execution/helpers/shell_ssh.py b/plugins/_code_execution/helpers/shell_ssh.py index 9aa9b4706a..f2ad37cbd2 100644 --- a/plugins/_code_execution/helpers/shell_ssh.py +++ b/plugins/_code_execution/helpers/shell_ssh.py @@ -73,7 +73,7 @@ async def connect(self, keepalive_interval: int = 5): full, part = await self.read_output() if full and not part: return - time.sleep(0.1) + await asyncio.sleep(0.1) except Exception as e: errors += 1 @@ -83,7 +83,7 @@ async def connect(self, keepalive_interval: int = 5): type="info", content=f"SSH Connection attempt {errors}...", ) - time.sleep(5) + await asyncio.sleep(5) else: raise e