π OpenHands: AI-Driven Development
Moved event search to background thread (#11487)
Tim O'Farrell054c5b666fcf
diff --git a/openhands/app_server/event/filesystem_event_service.py b/openhands/app_server/event/filesystem_event_service.pyindex cbcdf5e0cf..05e2ed9350 100644--- a/openhands/app_server/event/filesystem_event_service.py+++ b/openhands/app_server/event/filesystem_event_service.py@@ -1,5 +1,6 @@"""Filesystem-based EventService implementation."""+import asyncioimport globimport jsonimport logging@@ -76,6 +77,14 @@ class FilesystemEventService(EventService):data = event.model_dump(mode='json')f.write(json.dumps(data, indent=2))+ def _load_events_from_files(self, file_paths: list[Path]) -> list[Event]:+ events = []+ for file_path in file_paths:+ event = self._load_event_from_file(file_path)+ if event is not None:+ events.append(event)+ return events+def _load_event_from_file(self, filepath: Path) -> Event | None:"""Load an event from a file."""try:@@ -255,12 +264,11 @@ class FilesystemEventService(EventService):if start_index + limit < len(files):next_page_id = files[start_index + limit].name- # Load all events from files- page_events = []- for file_path in page_files:- event = self._load_event_from_file(file_path)- if event is not None:- page_events.append(event)+ # Load all events from files in a background thread.+ loop = asyncio.get_running_loop()+ page_events = await loop.run_in_executor(+ None, self._load_events_from_files, page_files+ )return EventPage(items=page_events, next_page_id=next_page_id)