From 4786acbc7dee1678fc32f96ebae388f810cb07c4 Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Mon, 21 Feb 2022 08:39:32 +0100 Subject: [PATCH] End of management of foreground in SSL context --- bin/runSalome.py | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/bin/runSalome.py b/bin/runSalome.py index e0c800e33..c190da15c 100755 --- a/bin/runSalome.py +++ b/bin/runSalome.py @@ -193,38 +193,53 @@ def main(exeName=None): def foreGround(args, ior_fakens_filename): # -- + gui_detected = False + dt = 0.1 + nbtot = 100 + nb = 0 if ior_fakens_filename is None: + logger.warn("No file set to host IOR of the fake naming server") return if not os.path.exists(ior_fakens_filename): + logger.warn("No file {} set to host IOR of the fake naming server does not exit !") return import CORBA import Engines + import SALOME + from time import sleep orb = CORBA.ORB_init([''], CORBA.ORB_ID) ior_fakens = None - try: - ior_fakens = orb.string_to_object(open(ior_fakens_filename).read()) - except Exception: - pass - session = orb.string_to_object(ior_fakens.Resolve("/Kernel/Session").decode()) + session = None + while True: + try: + ior_fakens = orb.string_to_object(open(ior_fakens_filename).read()) + session = orb.string_to_object(ior_fakens.Resolve("/Kernel/Session").decode()) + except Exception: + pass + if ( session is not None ) and (not CORBA.is_nil(session)): + logger.debug("Session in child process has been found ! yeah ! {}".format(str(session))) + break + sleep(dt) + nb += 1 + logger.debug("Unfortunately Session not found into {} : Sleep and retry. {}/{}".format(ior_fakens_filename,nb,nbtot)) + if nb == nbtot: + break + nb = 0 # -- # Wait until gui is arrived # tmax = nbtot * dt # -- - gui_detected = False - dt = 0.1 - nbtot = 100 - nb = 0 session_pid = None while 1: try: status = session.GetStatSession() gui_detected = status.activeGUI session_pid = session.getPID() + logger.debug("Process of the session under monitoring {}".format(session_pid)) except Exception: pass if gui_detected: break - from time import sleep sleep(dt) nb += 1 if nb == nbtot: -- 2.39.2