Skip to content

Commit

Permalink
add comment
Browse files Browse the repository at this point in the history
  • Loading branch information
shallmann committed May 31, 2024
1 parent 9f5065c commit e2c17b4
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions NuRadioReco/utilities/dataservers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import filelock
import logging
import shutil
from glob import glob

logger = logging.getLogger('NuRadioReco.dataservers')

Expand Down Expand Up @@ -61,11 +62,12 @@ def download_from_dataserver(remote_path, target_path, unpack_tarball=True, data

logger.warning(f"Assuring no other process is downloading. Will wait until {lockfile} is unlocked.")
with lock:
logger.warning(f"Locking {lockfile}")

if os.path.isfile(target_path):
logger.warning(f"{target_path} already exists. Maybe download was already completed by another instance?")
return
elif unpack_tarball and (len(glob(os.path.dirname(target_path) + "/*.dat")) > 0): #just check if any .dat files present (similar to NuRadioProposal.py)
logger.warning(f"{os.path.dirname(target_path)} contains .dat files. Maybe download was already completed by another instance?")
return

if try_ordered:
dataservers = get_available_dataservers_by_responsetime(dataservers)
Expand Down Expand Up @@ -110,4 +112,4 @@ def download_from_dataserver(remote_path, target_path, unpack_tarball=True, data
target_dir = os.path.dirname(target_path)
logger.warning(f"...unpacking archive to {target_dir}")
shutil.unpack_archive(target_path, target_dir)
#os.remove(target_path) do not remove for lock file
os.remove(target_path)

0 comments on commit e2c17b4

Please sign in to comment.