diff --git a/SAS/TMSS/backend/services/copy_service/copy_service.py b/SAS/TMSS/backend/services/copy_service/copy_service.py index 9609ee80241390ded10c2b8e73c3db2f43fc4655..223da1fccaff86f5f7074454685d14606b836590 100755 --- a/SAS/TMSS/backend/services/copy_service/copy_service.py +++ b/SAS/TMSS/backend/services/copy_service/copy_service.py @@ -39,14 +39,16 @@ class TMSSCopyServiceEventMessageHandler(TMSSEventMessageHandler): def start_handling(self): self.tmss_client.open() + super().start_handling() def stop_handling(self): + super().stop_handling() self.tmss_client.close() def before_receive_message(self): - # use 1-sec event loop to poll queued subtasks (rate limited at 30sec) + # use 1-sec event loop to poll queued subtasks (rate limited at 60sec) super().before_receive_message() - if datetime.utcnow() - self._last_df_check_timestamp > timedelta(seconds=30): + if datetime.utcnow() - self._last_df_check_timestamp > timedelta(seconds=60): self._last_df_check_timestamp = datetime.utcnow() self.check_and_run_queued_copy_subtask_if_enough_disk_space() @@ -84,9 +86,9 @@ class TMSSCopyServiceEventMessageHandler(TMSSEventMessageHandler): # determine destination host and root_dir destination = subtask['specifications_doc']['destination'] dst_host = destination[:destination.find(':')] if ':' in destination else '' - dst_root_dir = '/'+destination.lstrip(dst_host + ':').split('/')[1] - # strip unneeded localhost to prevent unneeded ssh calls - dst_host = dst_host.lstrip('localhost:').lstrip('127.0.0.1:') + dst_root_dir = '/'+destination.replace(dst_host + ':', '').split('/')[1] + # remove unneeded localhost to prevent unneeded ssh calls + dst_host = dst_host.replace('localhost:','').replace('127.0.0.1:','') df_cmd = ['df', dst_root_dir] if dst_host: @@ -157,11 +159,11 @@ class TMSSCopyServiceEventMessageHandler(TMSSEventMessageHandler): # split in host & parent_dir_path dst_host = output_dp_path[:output_dp_path.find(':')] if ':' in output_dp_path else '' - dst_parent_dir_path = output_dp_path.lstrip(dst_host + ':').rstrip(input_dataproduct['filename']) + dst_parent_dir_path = output_dp_path.replace(dst_host + ':','').replace(input_dataproduct['filename'],'') - # strip unneeded localhost to prevent under-the-hood ssh wrapping in rsync, and to prevent unneed ssh calls - dst_host = dst_host.lstrip('localhost:').lstrip('127.0.0.1:') - dst_parent_dir_path = dst_parent_dir_path.lstrip('localhost:').lstrip('127.0.0.1:') + # replace unneeded localhost to prevent under-the-hood ssh wrapping in rsync, and to prevent unneed ssh calls + dst_host = dst_host.replace('localhost:','').replace('127.0.0.1:', '') + dst_parent_dir_path = dst_parent_dir_path.replace('localhost:','').replace('127.0.0.1:','') if dst_parent_dir_path not in _created_dir_cache: # create dst_parent_dir_path directories if needed, prepend them to the cmd