diff options
author | Alexander_Kabui | 2024-01-17 21:02:32 +0300 |
---|---|---|
committer | Alexander_Kabui | 2024-01-17 21:02:32 +0300 |
commit | 2465bd38f184cb2ce3b94917f822e2be55390f24 (patch) | |
tree | 127680d8eb00f66208b19d950223d73823fdffa4 /gn3 | |
parent | 4468e59d1783e154612232f5da2d24a762d06681 (diff) | |
download | genenetwork3-2465bd38f184cb2ce3b94917f822e2be55390f24.tar.gz |
Adjust retry parameters and response handling in custom_request
Diffstat (limited to 'gn3')
-rw-r--r-- | gn3/llms/client.py | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/gn3/llms/client.py b/gn3/llms/client.py index 46ddc96..200cfd2 100644 --- a/gn3/llms/client.py +++ b/gn3/llms/client.py @@ -135,29 +135,28 @@ class GeneNetworkQAClient(Session): def custom_request(self, method, url, *args, **kwargs): - max_retries = 20 - retry_delay = 10 - - response = super().request(method, url, *args, **kwargs) + max_retries = 50 + retry_delay = 3 for i in range(max_retries): try: - + response = super().request(method, url, *args, **kwargs) response.raise_for_status() except requests.exceptions.RequestException as exc: - code = exc.response.status_code - if code == 422: + if exc.response.status_code == 422: raise UnprocessableEntity(exc.request, exc.response) # from exc elif i == max_retries - 1: raise exc if response.ok: - # Give time to get all the data - time.sleep(retry_delay*2) - return response + if method.lower() == "get" and response.json().get("data") is None: + time.sleep(retry_delay) + continue + else: + return response else: time.sleep(retry_delay) - return response + return response @staticmethod def get_task_id_from_result(response): |