Skip to content

Commit 76845d5

Browse files
committed
improve log messages with timeout data
* use format as 'x.xx' * use unit 's' * add timeout information if model execution fails
1 parent 478c0c9 commit 76845d5

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

OMPython/OMCSession.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ def run(self) -> int:
682682

683683
cmdl = self.get_cmd()
684684

685-
logger.debug("Run OM command %s in %s", repr(cmdl), self.cmd_path)
685+
logger.debug("Run OM command %s in %s (timeout=%2fs)", repr(cmdl), self.cmd_path, self.cmd_timeout)
686686
try:
687687
cmdres = subprocess.run(
688688
cmdl,
@@ -702,7 +702,8 @@ def run(self) -> int:
702702
if stderr:
703703
raise ModelExecutionException(f"Error running model executable {repr(cmdl)}: {stderr}")
704704
except subprocess.TimeoutExpired as ex:
705-
raise ModelExecutionException(f"Timeout running model executable {repr(cmdl)}: {ex}") from ex
705+
raise ModelExecutionException("OMPython timeout running model executable "
706+
f"(timeout={self.cmd_timeout:.2f}s){repr(cmdl)}: {ex}") from ex
706707
except subprocess.CalledProcessError as ex:
707708
raise ModelExecutionException(f"Error running model executable {repr(cmdl)}: {ex}") from ex
708709

@@ -1109,7 +1110,7 @@ def sendExpression(self, expr: str, parsed: bool = True) -> Any:
11091110
log_content = 'log not available'
11101111

11111112
logger.error(f"OMC did not start. Log-file says:\n{log_content}")
1112-
raise OMCSessionException(f"No connection with OMC (timeout={self._timeout}).")
1113+
raise OMCSessionException(f"No connection with OMC (timeout={self._timeout:.2f}s).")
11131114

11141115
if expr == "quit()":
11151116
self._omc_zmq.close()
@@ -1335,7 +1336,7 @@ def _omc_port_get(self) -> str:
13351336
break
13361337
else:
13371338
logger.error(f"OMC server did not start. Log-file says:\n{self.get_log()}")
1338-
raise OMCSessionException(f"OMC Server did not start (timeout={self._timeout}, "
1339+
raise OMCSessionException(f"OMC Server did not start (timeout={self._timeout:.2f}s, "
13391340
f"logfile={repr(self._omc_logfile)}).")
13401341

13411342
logger.info(f"Local OMC Server is up and running at ZMQ port {port} "
@@ -1462,7 +1463,7 @@ def _docker_process_get(self, docker_cid: str) -> Optional[DockerPopen]:
14621463
break
14631464
else:
14641465
logger.error(f"Docker did not start. Log-file says:\n{self.get_log()}")
1465-
raise OMCSessionException(f"Docker based OMC Server did not start (timeout={self._timeout}).")
1466+
raise OMCSessionException(f"Docker based OMC Server did not start (timeout={self._timeout:.2f}s).")
14661467

14671468
return docker_process
14681469

@@ -1500,7 +1501,7 @@ def _omc_port_get(self) -> str:
15001501
break
15011502
else:
15021503
logger.error(f"Docker did not start. Log-file says:\n{self.get_log()}")
1503-
raise OMCSessionException(f"Docker based OMC Server did not start (timeout={self._timeout}, "
1504+
raise OMCSessionException(f"Docker based OMC Server did not start (timeout={self._timeout:.2f}s, "
15041505
f"logfile={repr(self._omc_logfile)}).")
15051506

15061507
logger.info(f"Docker based OMC Server is up and running at port {port}")
@@ -1674,7 +1675,7 @@ def _docker_omc_start(self) -> Tuple[subprocess.Popen, DockerPopen, str]:
16741675
break
16751676
else:
16761677
logger.error(f"Docker did not start. Log-file says:\n{self.get_log()}")
1677-
raise OMCSessionException(f"Docker did not start (timeout={self._timeout} might be too short "
1678+
raise OMCSessionException(f"Docker did not start (timeout={self._timeout:.2f}s might be too short "
16781679
"especially if you did not docker pull the image before this command).")
16791680

16801681
docker_process = self._docker_process_get(docker_cid=docker_cid)
@@ -1854,7 +1855,7 @@ def _omc_port_get(self) -> str:
18541855
break
18551856
else:
18561857
logger.error(f"WSL based OMC server did not start. Log-file says:\n{self.get_log()}")
1857-
raise OMCSessionException(f"WSL based OMC Server did not start (timeout={self._timeout}, "
1858+
raise OMCSessionException(f"WSL based OMC Server did not start (timeout={self._timeout:2f}s, "
18581859
f"logfile={repr(self._omc_logfile)}).")
18591860

18601861
logger.info(f"WSL based OMC Server is up and running at ZMQ port {port} "

0 commit comments

Comments
 (0)