From c5219174d57810589e1b8813d3d7e5fd9976ec76 Mon Sep 17 00:00:00 2001 From: syntron Date: Thu, 23 Apr 2026 21:29:58 +0200 Subject: [PATCH 1/3] propagate timout seting to ModelExecutionCmd() * this was missing; default timout of 10.0s was always used --- OMPython/ModelicaSystem.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/OMPython/ModelicaSystem.py b/OMPython/ModelicaSystem.py index 03fd060b..01e5bfbd 100644 --- a/OMPython/ModelicaSystem.py +++ b/OMPython/ModelicaSystem.py @@ -451,6 +451,7 @@ def check_model_executable(self): cmd_local=self._session.model_execution_local, cmd_windows=self._session.model_execution_windows, cmd_prefix=self._session.model_execution_prefix(cwd=self.getWorkDirectory()), + timeout=self._session.set_timeout(), model_name=self._model_name, ) # ... by running it - output help for command help @@ -902,6 +903,7 @@ def simulate_cmd( cmd_local=self._session.model_execution_local, cmd_windows=self._session.model_execution_windows, cmd_prefix=self._session.model_execution_prefix(cwd=self.getWorkDirectory()), + timeout=self._session.set_timeout(), model_name=self._model_name, ) @@ -1394,6 +1396,7 @@ def linearize( cmd_local=self._session.model_execution_local, cmd_windows=self._session.model_execution_windows, cmd_prefix=self._session.model_execution_prefix(cwd=self.getWorkDirectory()), + timeout=self._session.set_timeout(), model_name=self._model_name, ) From 95f8e9c67ed9a2b1eaee53aea3786e485a035795 Mon Sep 17 00:00:00 2001 From: syntron Date: Thu, 23 Apr 2026 21:32:09 +0200 Subject: [PATCH 2/3] improve log messages with timeout data * use format as 'x.xx' * use unit 's' * add timeout information if model execution fails --- OMPython/OMCSession.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/OMPython/OMCSession.py b/OMPython/OMCSession.py index 731005f1..ed525212 100644 --- a/OMPython/OMCSession.py +++ b/OMPython/OMCSession.py @@ -856,7 +856,7 @@ def run(self) -> int: cmdl = self.get_cmd() - logger.debug("Run OM command %s in %s", repr(cmdl), self.cmd_path) + logger.debug("Run OM command %s in %s (timeout=%2fs)", repr(cmdl), self.cmd_path, self.cmd_timeout) try: cmdres = subprocess.run( cmdl, @@ -876,7 +876,8 @@ def run(self) -> int: if stderr: raise ModelExecutionException(f"Error running model executable {repr(cmdl)}: {stderr}") except subprocess.TimeoutExpired as ex: - raise ModelExecutionException(f"Timeout running model executable {repr(cmdl)}: {ex}") from ex + raise ModelExecutionException("OMPython timeout running model executable " + f"(timeout={self.cmd_timeout:.2f}s){repr(cmdl)}: {ex}") from ex except subprocess.CalledProcessError as ex: raise ModelExecutionException(f"Error running model executable {repr(cmdl)}: {ex}") from ex @@ -1282,7 +1283,7 @@ def sendExpression(self, expr: str, parsed: bool = True) -> Any: log_content = 'log not available' logger.error(f"OMC did not start. Log-file says:\n{log_content}") - raise OMCSessionException(f"No connection with OMC (timeout={self._timeout}).") + raise OMCSessionException(f"No connection with OMC (timeout={self._timeout:.2f}s).") if expr == "quit()": self._omc_zmq.close() @@ -1509,7 +1510,7 @@ def _omc_port_get(self) -> str: break else: logger.error(f"OMC server did not start. Log-file says:\n{self.get_log()}") - raise OMCSessionException(f"OMC Server did not start (timeout={self._timeout}, " + raise OMCSessionException(f"OMC Server did not start (timeout={self._timeout:.2f}s, " f"logfile={repr(self._omc_logfile)}).") logger.info(f"Local OMC Server is up and running at ZMQ port {port} " @@ -1648,7 +1649,7 @@ def _docker_process_get(self, docker_cid: str) -> Optional[DockerPopen]: break else: logger.error(f"Docker did not start. Log-file says:\n{self.get_log()}") - raise OMCSessionException(f"Docker based OMC Server did not start (timeout={self._timeout}).") + raise OMCSessionException(f"Docker based OMC Server did not start (timeout={self._timeout:.2f}s).") return docker_process @@ -1698,7 +1699,7 @@ def _omc_port_get( break else: logger.error(f"Docker did not start. Log-file says:\n{self.get_log()}") - raise OMCSessionException(f"Docker based OMC Server did not start (timeout={self._timeout}, " + raise OMCSessionException(f"Docker based OMC Server did not start (timeout={self._timeout:.2f}s, " f"logfile={repr(self._omc_logfile)}).") logger.info(f"Docker based OMC Server is up and running at port {port}") @@ -1885,7 +1886,7 @@ def _docker_omc_start( time.sleep(self._timeout / 40.0) if docker_cid is None: - raise OMCSessionException(f"Docker did not start (timeout={self._timeout} might be too short " + raise OMCSessionException(f"Docker did not start (timeout={self._timeout:.2f}s might be too short " "especially if you did not docker pull the image before this command). " f"Log-file says:\n{self.get_log()}") @@ -2076,7 +2077,7 @@ def _omc_port_get(self) -> str: break else: logger.error(f"WSL based OMC server did not start. Log-file says:\n{self.get_log()}") - raise OMCSessionException(f"WSL based OMC Server did not start (timeout={self._timeout}, " + raise OMCSessionException(f"WSL based OMC Server did not start (timeout={self._timeout:2f}s, " f"logfile={repr(self._omc_logfile)}).") logger.info(f"WSL based OMC Server is up and running at ZMQ port {port} " From 16402341216b3e72207e6cde13f0a73e1db1dfd3 Mon Sep 17 00:00:00 2001 From: syntron Date: Mon, 4 May 2026 21:14:57 +0200 Subject: [PATCH 3/3] remove old code - timeout loop handled within _timeout_loop() --- OMPython/OMCSession.py | 1 - 1 file changed, 1 deletion(-) diff --git a/OMPython/OMCSession.py b/OMPython/OMCSession.py index ed525212..04b5d9cc 100644 --- a/OMPython/OMCSession.py +++ b/OMPython/OMCSession.py @@ -1883,7 +1883,6 @@ def _docker_omc_start( pass if docker_cid is not None: break - time.sleep(self._timeout / 40.0) if docker_cid is None: raise OMCSessionException(f"Docker did not start (timeout={self._timeout:.2f}s might be too short "