]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
Improve waitNS function for more stable salome launch.
authormzn <mzn@opencascade.com>
Mon, 14 Nov 2005 15:40:39 +0000 (15:40 +0000)
committermzn <mzn@opencascade.com>
Mon, 14 Nov 2005 15:40:39 +0000 (15:40 +0000)
bin/orbmodule.py
bin/runSalome.py

index fdc254472e9a5fb5250001117863f42098337179..9dfad8a2c025352bfc27f3c26d07ff1a9473a56b 100755 (executable)
@@ -141,6 +141,36 @@ class client:
       if nobj is None:
             print "%s exists but is not a %s" % (name,typobj)
       return nobj
+   def waitNSPID(self, theName, thePID, theTypObj = None):
+      aCount = 0
+      aDelta = 0.5
+      anObj = None
+      print "Searching %s in Naming Service " % theName,
+      while(1):
+         try:
+            aPid, aStatus = os.waitpid(thePID,os.WNOHANG)
+         except Exception, exc:
+            raise "Impossible de trouver %s" % theName
+         aCount += 1
+         anObj = self.Resolve(theName)
+         if anObj: 
+            print " found in %s seconds " % ((aCount-1)*aDelta)
+            break
+         else:
+            sys.stdout.write('+')
+            sys.stdout.flush()
+            time.sleep(aDelta)
+            pass
+         pass
+      
+      if theTypObj is None:
+         return anObj
+
+      anObject = anObj._narrow(theTypObj)
+      if anObject is None:
+         print "%s exists but is not a %s" % (theName,theTypObj)
+      return anObject
+
 
    # --------------------------------------------------------------------------
 
index c3ac66070824e81d913b0b81bdb3d44577941456..df73e4977ba184a59b469c0d0ea4025597c6b562 100755 (executable)
@@ -229,6 +229,7 @@ class Server:
     """Generic class for CORBA server launch"""
 
     def initArgs(self):
+        self.PID=None
         self.CMD=[]
         self.ARGS=[]   
         if self.args['xterm']:
@@ -251,6 +252,7 @@ class Server:
         # print "command = ", command
         pid = os.spawnvp(os.P_NOWAIT, command[0], command)
         process_id[pid]=self.CMD
+        self.PID = pid
 
 
 class InterpServer(Server):
@@ -266,6 +268,7 @@ class InterpServer(Server):
         print "command = ", command
         pid = os.spawnvp(os.P_NOWAIT, command[0], command)
         process_id[pid]=self.CMD
+        self.PID = pid
 
 # ---
 
@@ -514,7 +517,7 @@ def startSalome(args, modules_list, modules_root_dir):
     if 'registry' not in args['embedded']:
         myServer=RegistryServer(args)
         myServer.run()
-        clt.waitNS("/Registry")
+        clt.waitNSPID("/Registry",myServer.PID)
 
     #
     # Lancement Catalog Server,
@@ -527,7 +530,7 @@ def startSalome(args, modules_list, modules_root_dir):
         cataServer.setpath(modules_list,modules_root_dir)
         cataServer.run()
         import SALOME_ModuleCatalog
-        clt.waitNS("/Kernel/ModulCatalog",SALOME_ModuleCatalog.ModuleCatalog)
+        clt.waitNSPID("/Kernel/ModulCatalog",cataServer.PID,SALOME_ModuleCatalog.ModuleCatalog)
 
     #
     # Lancement SalomeDS Server,
@@ -554,7 +557,7 @@ def startSalome(args, modules_list, modules_root_dir):
     if 'study' not in args['embedded']:
         myServer=SalomeDSServer(args)
         myServer.run()
-        clt.waitNS("/myStudyManager")
+        clt.waitNSPID("/myStudyManager",myServer.PID)
 
     #
     # Lancement ContainerManagerServer
@@ -579,7 +582,7 @@ def startSalome(args, modules_list, modules_root_dir):
     #
 
     import SALOME
-    session=clt.waitNS("/Kernel/Session",SALOME.Session)
+    session=clt.waitNSPID("/Kernel/Session",mySessionServ.PID,SALOME.Session)
 
     from Utils_Identity import getShortHostName
     
@@ -599,7 +602,7 @@ def startSalome(args, modules_list, modules_root_dir):
     if 'cppContainer' in args['standalone']:
         myServer=ContainerCPPServer(args)
         myServer.run()
-        clt.waitNS("/Containers/" + theComputer + "/FactoryServer")
+        clt.waitNSPID("/Containers/" + theComputer + "/FactoryServer",myServer.PID)
 
     #
     # Lancement Container Python local,
@@ -610,7 +613,7 @@ def startSalome(args, modules_list, modules_root_dir):
     if 'pyContainer' in args['standalone']:
         myServer=ContainerPYServer(args)
         myServer.run()
-        clt.waitNS("/Containers/" + theComputer + "/FactoryServerPy")
+        clt.waitNSPID("/Containers/" + theComputer + "/FactoryServerPy",myServer.PID)
 
     #
     # Lancement Container Supervision local,
@@ -621,7 +624,7 @@ def startSalome(args, modules_list, modules_root_dir):
     if 'supervContainer' in args['standalone']:
         myServer=ContainerSUPERVServer(args)
         myServer.run()
-        clt.waitNS("/Containers/" + theComputer + "/SuperVisionContainer")
+        clt.waitNSPID("/Containers/" + theComputer + "/SuperVisionContainer",myServer.PID)
 
     end_time = os.times()
     print