Skip to content

Commit

Permalink
Merge pull request #7 from oztqa/TRAVELQA-530
Browse files Browse the repository at this point in the history
[TRAVELQA-530] - support request_timeout param for init
  • Loading branch information
griddic authored Feb 4, 2020
2 parents 553788a + 69d7a4d commit ca33c57
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion reqtools/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@
class RemoteApiSession(Session):
__attrs__ = Session.__attrs__ + ['_base_url', '_prefix']

def __init__(self, base_url: str, *, prefix: str = None):
def __init__(self, base_url: str, *, prefix: str = None, request_timeout: int = None):
super().__init__()

self._base_url = base_url
self._prefix = prefix
self._request_timeout = request_timeout

def __repr__(self):
return f'{self.__class__.__name__}({self.url})'
Expand All @@ -35,6 +36,8 @@ def url(self):
return self._build_url(self._base_url, self._prefix)

def request(self, method: str, url_path: str, **kwargs):
if self._request_timeout:
kwargs.setdefault('timeout', self._request_timeout)

url = self._build_url(self.url, url_path)

Expand Down

0 comments on commit ca33c57

Please sign in to comment.