Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase task ping interval #76

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading