Skip to content

Commit

Permalink
modified: hera_pspec/pspecdata.py
Browse files Browse the repository at this point in the history
  • Loading branch information
nkern committed Jul 10, 2019
1 parent 1cbf5b9 commit a91cc2d
Showing 1 changed file with 6 additions and 16 deletions.
22 changes: 6 additions & 16 deletions hera_pspec/pspecdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -3157,8 +3157,8 @@ def pspec_run(dsets, filename, dsets_std=None, cals=None, cal_flag=True,
bls2_list.append(_bls2)

# Open PSpecContainer to store all output in
if verbose: print("Opening {}".format(filename))
psc = container.PSpecContainer(filename, mode='rw', keep_open=False)
if verbose: print("Opening {} in transactional mode".format(filename))
psc = container.PSpecContainer(filename, mode='rw', keep_open=False, tsleep=1, maxiter=20)

# assign group name
if groupname is None:
Expand All @@ -3179,21 +3179,11 @@ def pspec_run(dsets, filename, dsets_std=None, cals=None, cal_flag=True,
# Store output
psname = '{}_x_{}{}'.format(dset_labels[dset_idxs[0]],
dset_labels[dset_idxs[1]], psname_ext)

# write in transactional mode
if verbose: print("Storing {}".format(psname))
# possibly multiple writers per container, so handle file locking
Ncount = 0
while Ncount < 10:
try:
# open, write, then close it
psc = container.PSpecContainer(filename, mode='rw')
psc.set_pspec(group=groupname, psname=psname, pspec=uvp,
overwrite=overwrite)
del psc
break
except (OSError, IOError):
# if file is locked, wait 5 seconds and try again
time.sleep(5)
Ncount += 1
psc.set_pspec(group=groupname, psname=psname, pspec=uvp,
overwrite=overwrite)

return ds

Expand Down

0 comments on commit a91cc2d

Please sign in to comment.