From b4b59f1bc57b50a3eafb2761d912b9cd9e6f3371 Mon Sep 17 00:00:00 2001 From: Henrique Salvaro Furtado Date: Tue, 8 Oct 2024 12:05:32 -0700 Subject: [PATCH] feat: Use Unit timeout value on request's timeout (#2) --- unit/api/base_resource.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/unit/api/base_resource.py b/unit/api/base_resource.py index ff42960b..05815e8f 100644 --- a/unit/api/base_resource.py +++ b/unit/api/base_resource.py @@ -49,7 +49,7 @@ def get(self, resource: str, params: Dict = None, headers: Optional[Dict[str, st max_time=self.configuration.get_timeout, jitter=backoff.random_jitter) def get_with_backoff(path: str, p: Dict, h: Dict[str, str]): - return requests.get(path, params=p, headers=h) + return requests.get(path, params=p, headers=h, timeout=self.configuration.get_timeout()) return get_with_backoff(f"{self.configuration.api_url}/{resource}", params, self.__merge_headers(headers)) @@ -62,7 +62,7 @@ def post(self, resource: str, data: Optional[Dict] = None, headers: Optional[Dic max_time=self.configuration.get_timeout, jitter=backoff.random_jitter) def post_with_backoff(path: str, d: Dict, h: Dict[str, str]): - return requests.post(path, data=d, headers=h) + return requests.post(path, data=d, headers=h, timeout=self.configuration.get_timeout()) return post_with_backoff(f"{self.configuration.api_url}/{resource}", data, self.__merge_headers(headers)) @@ -75,7 +75,7 @@ def post_create(self, resource: str, data: Optional[Dict] = None, headers: Optio max_time=self.configuration.get_timeout, jitter=backoff.random_jitter) def post_create_with_backoff(path: str, d, h): - return requests.post(path, data=d, headers=h) + return requests.post(path, data=d, headers=h, timeout=self.configuration.get_timeout()) return post_create_with_backoff(f"{self.configuration.api_url}/{resource}", data, self.__merge_headers(headers)) @@ -88,7 +88,7 @@ def post_full_path(self, path: str, data: Optional[Dict] = None, headers: Option max_time=self.configuration.get_timeout, jitter=backoff.random_jitter) def post_full_path_with_backoff(p, d, h): - return requests.post(p, data=d, headers=h) + return requests.post(p, data=d, headers=h, timeout=self.configuration.get_timeout()) return post_full_path_with_backoff(path, data, self.__merge_headers(headers)) @@ -101,7 +101,7 @@ def patch(self, resource: str, data: Optional[Dict] = None, headers: Optional[Di max_time=self.configuration.get_timeout, jitter=backoff.random_jitter) def patch_with_backoff(p, d, h): - return requests.patch(p, data=d, headers=h) + return requests.patch(p, data=d, headers=h, timeout=self.configuration.get_timeout()) return patch_with_backoff(f"{self.configuration.api_url}/{resource}", data, self.__merge_headers(headers)) @@ -114,7 +114,7 @@ def delete(self, resource: str, data: Dict = None, headers: Optional[Dict[str, s max_time=self.configuration.get_timeout, jitter=backoff.random_jitter) def delete_with_backoff(p, d, h): - return requests.delete(p, data=d, headers=h) + return requests.delete(p, data=d, headers=h, timeout=self.configuration.get_timeout()) return delete_with_backoff(f"{self.configuration.api_url}/{resource}", data, self.__merge_headers(headers)) @@ -125,7 +125,7 @@ def put(self, resource: str, data: Optional[Dict] = None, headers: Optional[Dict max_time=self.configuration.get_timeout, jitter=backoff.random_jitter) def put_with_backoff(p, d, h): - return requests.put(p, data=d, headers=h) + return requests.put(p, data=d, headers=h, timeout=self.configuration.get_timeout()) return put_with_backoff(f"{self.configuration.api_url}/{resource}", data, self.__merge_headers(headers))