Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions OMPython/ModelicaSystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
)

Expand Down Expand Up @@ -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,
)

Expand Down
18 changes: 9 additions & 9 deletions OMPython/OMCSession.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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

Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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} "
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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}")
Expand Down Expand Up @@ -1882,10 +1883,9 @@ 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} 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()}")

Expand Down Expand Up @@ -2076,7 +2076,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} "
Expand Down
Loading