From 3454d640afacac24e1c958a60ba7b55ad9326584 Mon Sep 17 00:00:00 2001 From: =?utf8?q?C=C3=A9dric=20Aguerre?= Date: Wed, 4 Mar 2015 12:10:48 +0100 Subject: [PATCH] prevent from double session close --- bin/killSalomeWithPort.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/bin/killSalomeWithPort.py b/bin/killSalomeWithPort.py index cc1d5b958..c340e4863 100755 --- a/bin/killSalomeWithPort.py +++ b/bin/killSalomeWithPort.py @@ -201,7 +201,8 @@ def shutdownMyPort(port, cleanup=True): from LifeCycleCORBA import LifeCycleCORBA # shutdown all orb = CORBA.ORB_init([''], CORBA.ORB_ID) - lcc = LifeCycleCORBA(orb) + lcc = LifeCycleCORBA(orb) # see (1) + print "Terminating SALOME on port %s..."%(port) lcc.shutdownServers() # give some time to shutdown to complete time.sleep(1) @@ -213,7 +214,13 @@ def shutdownMyPort(port, cleanup=True): pass except: pass + exit(0) # see (1) pass +# (1) If --shutdown-servers option is set to 1, session close procedure is +# called twice: first explicitely by salome command, second by automatic +# atexit to handle Ctrl-C. During second call, LCC does not exist anymore and +# a RuntimeError is raised; we explicitely exit this function with code 0 to +# prevent parent thread from crashing. def __killMyPort(port, filedict): # bug fix: ensure port is an integer @@ -359,12 +366,18 @@ def killMyPort(port): Parameters: - port - port number """ - print "Terminating SALOME on port %s..."%(port) - # bug fix: ensure port is an integer if port: port = int(port) + try: + import PortManager # do not remove! Test for PortManager availability! + filedict = getPiDict(port) + if not os.path.isfile(filedict): # removed by previous call, see (1) + return + except: + pass + # try to shutdown session normally import threading, time threading.Thread(target=shutdownMyPort, args=(port,False)).start() -- 2.39.2