Skip to content

Commit 57efc8c

Browse files
committed
[OMCSession*] define set_timeout()
1 parent 582d76d commit 57efc8c

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

OMPython/OMCSession.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,17 @@ def __del__(self):
602602

603603
self.omc_zmq = None
604604

605+
def set_timeout(self, timeout: Optional[float] = None) -> float:
606+
"""
607+
Set the timeout to be used for OMC communication (OMCSession).
608+
"""
609+
retval = self._timeout
610+
if timeout is not None:
611+
if timeout <= 0.0:
612+
raise OMCSessionException(f"Invalid timeout value: {timeout}!")
613+
self._timeout = timeout
614+
return retval
615+
605616
@staticmethod
606617
def escape_str(value: str) -> str:
607618
"""
@@ -661,11 +672,9 @@ def omc_run_data_update(self, omc_run_data: OMCSessionRunData) -> OMCSessionRunD
661672
"""
662673
return self.omc_process.omc_run_data_update(omc_run_data=omc_run_data)
663674

664-
@staticmethod
665-
def run_model_executable(cmd_run_data: OMCSessionRunData) -> int:
675+
def run_model_executable(self, cmd_run_data: OMCSessionRunData) -> int:
666676
"""
667-
Run the command defined in cmd_run_data. This class is defined as static method such that there is no need to
668-
keep instances of over classes around.
677+
Run the command defined in cmd_run_data.
669678
"""
670679

671680
my_env = os.environ.copy()
@@ -682,7 +691,7 @@ def run_model_executable(cmd_run_data: OMCSessionRunData) -> int:
682691
text=True,
683692
env=my_env,
684693
cwd=cmd_run_data.cmd_cwd_local,
685-
timeout=cmd_run_data.cmd_timeout,
694+
timeout=self._timeout,
686695
check=True,
687696
)
688697
stdout = cmdres.stdout.strip()

0 commit comments

Comments
 (0)