Skip to content

Commit fe9bf71

Browse files
committed
[OMCProcessDocker*] reworked inheritance chain - use change for _omc_process_docker()
1 parent 256c73a commit fe9bf71

1 file changed

Lines changed: 6 additions & 11 deletions

File tree

OMPython/OMCSession.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -613,18 +613,17 @@ def __init__(self, **kwargs) -> None:
613613
self._dockerCid: Optional[str] = None
614614
self._docker_process: Optional[DummyPopen] = None
615615

616-
@staticmethod
617-
def _omc_process_docker(dockerCid: str, random_string: str, timeout: float) -> Optional[DummyPopen]:
616+
def _omc_process_docker(self) -> Optional[DummyPopen]:
618617
if sys.platform == 'win32':
619618
raise NotImplementedError("Docker not supported on win32!")
620619

621620
docker_process = None
622621
for idx in range(0, 40):
623-
dockerTop = subprocess.check_output(["docker", "top", dockerCid]).decode().strip()
622+
dockerTop = subprocess.check_output(["docker", "top", self._dockerCid]).decode().strip()
624623
docker_process = None
625624
for line in dockerTop.split("\n"):
626625
columns = line.split()
627-
if random_string in line:
626+
if self._random_string in line:
628627
try:
629628
docker_process = DummyPopen(int(columns[1]))
630629
except psutil.NoSuchProcess as ex:
@@ -633,7 +632,7 @@ def _omc_process_docker(dockerCid: str, random_string: str, timeout: float) -> O
633632

634633
if docker_process is not None:
635634
break
636-
time.sleep(timeout / 40.0)
635+
time.sleep(self._timeout / 40.0)
637636

638637
return docker_process
639638

@@ -833,9 +832,7 @@ def _omc_docker_start(self) -> Tuple[subprocess.Popen, DummyPopen, str]:
833832
raise OMCSessionException(f"Docker did not start (timeout={self._timeout} might be too short "
834833
"especially if you did not docker pull the image before this command).")
835834

836-
docker_process = self._omc_process_docker(dockerCid=docker_cid,
837-
random_string=self._random_string,
838-
timeout=self._timeout)
835+
docker_process = self._omc_process_docker()
839836
if docker_process is None:
840837
raise OMCSessionException(f"Docker top did not contain omc process {self._random_string}. "
841838
f"Log-file says:\n{self.get_log()}")
@@ -958,9 +955,7 @@ def _omc_docker_start(self) -> Tuple[subprocess.Popen, DummyPopen]:
958955

959956
docker_process = None
960957
if isinstance(self._dockerCid, str):
961-
docker_process = self._omc_process_docker(dockerCid=self._dockerCid,
962-
random_string=self._random_string,
963-
timeout=self._timeout)
958+
docker_process = self._omc_process_docker()
964959

965960
if docker_process is None:
966961
raise OMCSessionException(f"Docker top did not contain omc process {self._random_string} "

0 commit comments

Comments
 (0)