Skip to content

feat: Use Unit timeout value on request's timeout #292

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
14 changes: 7 additions & 7 deletions unit/api/base_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand All @@ -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))

Expand All @@ -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))

Expand All @@ -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))

Expand All @@ -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))

Expand All @@ -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))

Expand All @@ -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))

Expand Down