From 14e9cd8b6f6978cad341b0dcf2d1509b482ba2a4 Mon Sep 17 00:00:00 2001 From: xjules Date: Fri, 6 Sep 2024 13:53:03 +0200 Subject: [PATCH 1/2] Run snapshot_update in executor send_snapshot_event could be more CPU bound that initially though and thus suggestion is to run in executor. --- src/ert/run_models/base_run_model.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/ert/run_models/base_run_model.py b/src/ert/run_models/base_run_model.py index 79b496548ad..6f18583720a 100644 --- a/src/ert/run_models/base_run_model.py +++ b/src/ert/run_models/base_run_model.py @@ -447,7 +447,13 @@ async def run_monitor( EESnapshotUpdate, ): event = cast(Union[EESnapshot, EESnapshotUpdate], event) - self.send_snapshot_event(event, iteration) + await asyncio.get_running_loop().run_in_executor( + None, + self.send_snapshot_event, + event, + iteration, + ) + if event.snapshot.get(STATUS) in [ ENSEMBLE_STATE_STOPPED, ENSEMBLE_STATE_FAILED, From 2ef5e2fbff5f42a2f572d23e6823e6cc632d5391 Mon Sep 17 00:00:00 2001 From: xjules Date: Fri, 6 Sep 2024 13:54:10 +0200 Subject: [PATCH 2/2] Assert that last event in status_queue is an EndEvent --- tests/integration_tests/status/test_tracking_integration.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/integration_tests/status/test_tracking_integration.py b/tests/integration_tests/status/test_tracking_integration.py index 7a8c88996be..646b25af810 100644 --- a/tests/integration_tests/status/test_tracking_integration.py +++ b/tests/integration_tests/status/test_tracking_integration.py @@ -206,6 +206,9 @@ def test_tracking( snapshots: Dict[str, Snapshot] = {} thread.join() + + assert isinstance(queue.events[-1], EndEvent) + for event in queue: if isinstance(event, FullSnapshotEvent): snapshots[event.iteration] = event.snapshot