Skip to content
Snippets Groups Projects
Commit 91113467 authored by Izzard's avatar Izzard
Browse files

added NFS file locking with flufl.lock()

parent b0d8e176
No related merge requests found
......@@ -9,6 +9,7 @@
Condor API.
"""
import datetime
import flufl.lock
import glob
import os
import pathlib
......@@ -79,17 +80,33 @@ class HPC(condor,slurm):
self.exit(code=1)
x = False
else:
# write the joiningfile
print("Making joiningfile at {file} with range 0 to {n}".format(
file=file,
n=n
))
with open(file,"w",encoding="utf-8") as f:
for i in range(0,n):
f.write(os.path.join(prefix,
"{i}.gz\n".format(i=i)))
f.close()
x = True
# lock the joiningfile
lock = flufl.lock.Lock(file)
# writing this file should not take > 1 hour
lock.lifetime = datetime.timedelta(seconds=3600)
if os.path.isfile(file):
print("Cannot make joiningfile at {file} because it already exists.".format(file=file))
x = False
else:
if lock.is_locked:
# write the joiningfile
print("Making joiningfile at {file} with range 0 to {n}".format(
file=file,
n=n
))
with open(file,"w",encoding="utf-8") as f:
for i in range(0,n):
f.write(os.path.join(prefix,
"{i}.gz\n".format(i=i)))
x = True
else:
print("Could not lock joiningfile at {file}".format(file=file))
x = False
# unlock the file
lock.unlock()
return x
def HPC_joinfiles(self,joinlist=None):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment