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
16 changes: 12 additions & 4 deletions OMPython/ModelicaSystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
# define logger using the current module name as ID
logger = logging.getLogger(__name__)

MODEL_EXECUTION_TIMEOUT: float = 300.0


class ModelicaSystemError(Exception):
"""
Expand Down Expand Up @@ -108,7 +110,7 @@ def __init__(
cmd_prefix: list[str],
cmd_local: bool = False,
cmd_windows: bool = False,
timeout: float = 300.0,
timeout: Optional[float] = None,
model_name: Optional[str] = None,
) -> None:
if model_name is None:
Expand All @@ -119,7 +121,13 @@ def __init__(
self._cmd_prefix = cmd_prefix
self._runpath = pathlib.PurePosixPath(runpath)
self._model_name = model_name
self._timeout = timeout

if timeout is None:
# a separate timeout is defined here to allow the use of the class independent of the normal call chain via
# classes derived from OMSession (OMSESSION_TIMEOUT)
self._timeout: float = MODEL_EXECUTION_TIMEOUT
else:
self._timeout = timeout

# dictionaries of command line arguments for the model executable
self._args: dict[str, str | None] = {}
Expand Down Expand Up @@ -2830,14 +2838,14 @@ def _prepare_structure_parameters(

class ModelicaSystemCmd(ModelExecutionCmd):
"""
Compatibility class; in the new version it is renamed as MOdelExecutionCmd.
Compatibility class; in the new version it is renamed as ModelExecutionCmd.
"""

def __init__(
self,
runpath: pathlib.Path,
modelname: str,
timeout: float = 300.0,
timeout: Optional[float] = None,
) -> None:
super().__init__(
runpath=runpath,
Expand Down
6 changes: 4 additions & 2 deletions OMPython/OMCSession.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
# define logger using the current module name as ID
logger = logging.getLogger(__name__)

OMSESSION_TIMEOUT: float = 300.0


class DockerPopen:
"""
Expand Down Expand Up @@ -953,7 +955,7 @@ def __init__(
self.model_execution_local = False

# store variables
self._timeout = 300.0
self._timeout = OMSESSION_TIMEOUT
self.set_timeout(timeout=timeout)
# command prefix (to be used for docker or WSL)
self._cmd_prefix: list[str] = []
Expand Down Expand Up @@ -2113,7 +2115,7 @@ class OMSessionRunner(OMSessionRunnerABC):
def __init__(
self,
ompath_runner: Type[OMPathRunnerABC] = OMPathRunnerLocal,
timeout: float = 10.0,
timeout: Optional[float] = None,
version: str = "1.27.0",
cmd_prefix: Optional[list[str]] = None,
model_execution_local: bool = True,
Expand Down
Loading