Skip to content

Commit

Permalink
fix/simplify retry loop in provision_run_dir
Browse files Browse the repository at this point in the history
  • Loading branch information
mlin committed Apr 12, 2020
1 parent 7a77fff commit e6d5402
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions WDL/_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,24 +198,14 @@ def provision_run_dir(name: str, run_dir: Optional[str], last_link: bool = False
return run_dir

# create timestamp-named directory
now = datetime.today()
new_dir = os.path.join(run_dir, now.strftime("%Y%m%d_%H%M%S") + "_" + name)
try:
os.makedirs(new_dir, exist_ok=False)
except FileExistsError:
new_dir = None

new_dir = None
while not new_dir:
# it already exists; try adding milliseconds
new_dir = os.path.join(
run_dir,
now.strftime("%Y%m%d_%H%M%S_") + str(int(now.microsecond / 1000)).zfill(3) + "_" + name,
)
new_dir = os.path.join(run_dir, datetime.today().strftime("%Y%m%d_%H%M%S") + "_" + name)
try:
os.makedirs(new_dir, exist_ok=False)
except FileExistsError:
new_dir = None
sleep(1e-3)
sleep(0.5)
assert new_dir

# update the _LAST link
Expand Down

0 comments on commit e6d5402

Please sign in to comment.