From 4243a595e400e0663cfcabc1a31ccc1ae6de6475 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Fri, 14 Aug 2026 19:23:13 +0000 Subject: [PATCH] Perf: Optimize monitoring script file saving with async I/O Replaces synchronous file operations with `aiofiles` in `archive/v1/scripts/test_monitoring.py` to prevent blocking the asyncio event loop while saving test results. Co-authored-by: manupawickramasinghe <73810867+manupawickramasinghe@users.noreply.github.com> --- archive/v1/scripts/test_monitoring.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/archive/v1/scripts/test_monitoring.py b/archive/v1/scripts/test_monitoring.py index 66241d6ba3..c1a141b3ce 100755 --- a/archive/v1/scripts/test_monitoring.py +++ b/archive/v1/scripts/test_monitoring.py @@ -7,6 +7,7 @@ import aiohttp import json import sys +import aiofiles from datetime import datetime from typing import Dict, Any, List import time @@ -335,8 +336,8 @@ async def run_all_tests(self): print(f" - {result['test']}: {result.get('error', 'Unknown error')}") # Save results - with open("monitoring_test_results.json", "w") as f: - json.dump({ + async with aiofiles.open("monitoring_test_results.json", "w") as f: + data = { "timestamp": datetime.now().isoformat(), "base_url": self.base_url, "summary": { @@ -345,7 +346,8 @@ async def run_all_tests(self): "failed": failed }, "results": self.results - }, f, indent=2) + } + await f.write(json.dumps(data, indent=2)) print("\nResults saved to monitoring_test_results.json")