Skip to content

Commit

Permalink
Increase task ping interval
Browse files Browse the repository at this point in the history
  • Loading branch information
devincowan committed Nov 13, 2024
1 parent a2f4d88 commit edd8124
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions hsclient/hydroshare.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@
from hsclient.oauth2_model import Token
from hsclient.utils import attribute_filter, encode_resource_url, is_aggregation, main_file_type

CHECK_TASK_PING_INTERVAL = 10


class File(str):
"""
Expand Down Expand Up @@ -1274,7 +1276,7 @@ def aggregation_move(self, aggregation: Aggregation, dst_path: str = "") -> None
status = json_response['status']
if status in ("Not ready", "progress"):
while aggregation._hs_session.check_task(task_id) != 'true':
time.sleep(1)
time.sleep(CHECK_TASK_PING_INTERVAL)
aggregation.refresh()

@refresh
Expand Down Expand Up @@ -1368,7 +1370,7 @@ def retrieve_bag(self, path, save_path=""):
file = self.get(path, status_code=200, allow_redirects=True)

if file.headers['Content-Type'] != "application/zip":
time.sleep(1)
time.sleep(CHECK_TASK_PING_INTERVAL)
return self.retrieve_bag(path, save_path)
return self.retrieve_file(path, save_path)

Expand All @@ -1386,7 +1388,7 @@ def retrieve_zip(self, path, save_path="", params=None):
zip_status = json_response['zip_status']
if zip_status == "Not ready":
while self.check_task(task_id) != 'true':
time.sleep(1)
time.sleep(CHECK_TASK_PING_INTERVAL)
return self.retrieve_file(download_path, save_path)

def upload_file(self, path, files, status_code=204):
Expand Down

0 comments on commit edd8124

Please sign in to comment.