Skip to content

Commit

Permalink
Merge pull request #941 from ganga-devs/getDiracCommandIncludes-Race-…
Browse files Browse the repository at this point in the history
…Condition

Protect reading of file with Dirac commands against race condition
  • Loading branch information
Ulrik Egede committed Feb 6, 2017
2 parents fbeaf1e + d963649 commit 7324014
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions python/GangaDirac/Lib/Utilities/DiracUtilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,13 @@ def getDiracCommandIncludes(force=False):
force (bool): Triggers a reload from disk when True
"""
global DIRAC_INCLUDE
if DIRAC_INCLUDE == '' or force:
for fname in getConfig('DIRAC')['DiracCommandFiles']:
if not os.path.exists(fname):
raise RuntimeError("Specified Dirac command file '%s' does not exist." % fname)
with open(fname, 'r') as inc_file:
DIRAC_INCLUDE += inc_file.read() + '\n'
with Dirac_Env_Lock:
if DIRAC_INCLUDE == '' or force:
for fname in getConfig('DIRAC')['DiracCommandFiles']:
if not os.path.exists(fname):
raise RuntimeError("Specified Dirac command file '%s' does not exist." % fname)
with open(fname, 'r') as inc_file:
DIRAC_INCLUDE += inc_file.read() + '\n'

return DIRAC_INCLUDE

Expand Down

0 comments on commit 7324014

Please sign in to comment.