Skip to content

Commit 0067e1b

Browse files
committed
[OM(C)SessionABC] small fixes
* comments * prepare cmd_prefix handling within OMSession * fix timeout handling
1 parent ae77187 commit 0067e1b

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

OMPython/OMCSession.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -809,12 +809,20 @@ def __init__(
809809

810810
# store variables
811811
self._timeout = timeout
812+
# command prefix (to be used for docker or WSL)
813+
self._cmd_prefix: list[str] = []
812814

813815
def __post_init__(self) -> None:
814816
"""
815817
Post initialisation method.
816818
"""
817819

820+
def get_cmd_prefix(self) -> list[str]:
821+
"""
822+
Get session definition used for this instance of OMPath.
823+
"""
824+
return self._cmd_prefix.copy()
825+
818826
@staticmethod
819827
def escape_str(value: str) -> str:
820828
"""
@@ -843,7 +851,7 @@ def set_workdir(self, workdir: OMPathABC) -> None:
843851
@abc.abstractmethod
844852
def omcpath(self, *path) -> OMPathABC:
845853
"""
846-
Create an OMPathBase object based on the given path segments and the current class.
854+
Create an OMPathABC object based on the given path segments and the current class.
847855
"""
848856

849857
@abc.abstractmethod
@@ -907,13 +915,12 @@ def __init__(
907915
"""
908916
Initialisation for OMCSession
909917
"""
918+
super().__init__(timeout=timeout)
910919

911920
# some helper data
912921
self.model_execution_windows = platform.system() == "Windows"
913922
self.model_execution_local = False
914923

915-
# store variables
916-
self._timeout = timeout
917924
# generate a random string for this instance of OMC
918925
self._random_string = uuid.uuid4().hex
919926
# get a temporary directory
@@ -990,6 +997,7 @@ def __del__(self):
990997
self._omc_process.kill()
991998
self._omc_process.wait()
992999
finally:
1000+
9931001
self._omc_process = None
9941002

9951003
def _timeout_loop(

0 commit comments

Comments
 (0)