From 7bc1ac5314202ff2ae52027e8f5af341f642499c Mon Sep 17 00:00:00 2001 From: =?utf8?q?C=C3=A9dric=20Aguerre?= Date: Wed, 5 Apr 2017 16:38:57 +0200 Subject: [PATCH] PortManager info must be shared by applications; so they go to temporary folder --- bin/PortManager.py | 4 ++++ bin/salomeContextUtils.py.in | 24 +++++++++++++++++------- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/bin/PortManager.py b/bin/PortManager.py index 18350254d..7e83d4696 100644 --- a/bin/PortManager.py +++ b/bin/PortManager.py @@ -49,6 +49,7 @@ logger = createLogger() #------------------------------------ # A file locker def __acquire_lock(lock): + logger.debug("ACQUIRE LOCK") if sys.platform == "win32": import msvcrt # lock 1 byte: file is supposed to be zero-byte long @@ -56,14 +57,17 @@ def __acquire_lock(lock): else: import fcntl fcntl.flock(lock, fcntl.LOCK_EX) + logger.debug("LOCK ACQUIRED") # def __release_lock(lock): + logger.debug("RELEASE LOCK") if sys.platform == "win32": import msvcrt msvcrt.locking(lock.fileno(), msvcrt.LK_UNLCK, 1) else: import fcntl fcntl.flock(lock, fcntl.LOCK_UN) + logger.debug("LOCK RELEASED") # #------------------------------------ diff --git a/bin/salomeContextUtils.py.in b/bin/salomeContextUtils.py.in index 7f9151bcf..c078c96fe 100644 --- a/bin/salomeContextUtils.py.in +++ b/bin/salomeContextUtils.py.in @@ -320,13 +320,23 @@ def setOmniOrbUserPath(): raise Exception("Unable to get write access to directory: %s"%omniorbUserPath) pass else: - homePath = os.path.realpath(os.path.expanduser('~')) - #defaultOmniorbUserPath = os.path.join(homePath, ".salomeConfig/USERS") - defaultOmniorbUserPath = homePath - if os.getenv("APPLI"): - defaultOmniorbUserPath = os.path.join(homePath, os.getenv("APPLI"), "USERS") - pass - os.environ["OMNIORB_USER_PATH"] = defaultOmniorbUserPath + # Must be in /tmp (or equivalent) to handle application concurrency + try: + import tempfile + temp = tempfile.NamedTemporaryFile() + temp_dir = os.path.dirname(temp.name) + temp.close() + if not os.access(temp_dir, os.W_OK): + raise Exception("Unable to get write access to directory: %s"%temp_dir) + os.environ["OMNIORB_USER_PATH"] = temp_dir + except: + homePath = os.path.realpath(os.path.expanduser('~')) + #defaultOmniorbUserPath = os.path.join(homePath, ".salomeConfig/USERS") + defaultOmniorbUserPath = homePath + if os.getenv("APPLI"): + defaultOmniorbUserPath = os.path.join(homePath, os.getenv("APPLI"), "USERS") + pass + os.environ["OMNIORB_USER_PATH"] = defaultOmniorbUserPath # def getHostname(): -- 2.39.2