Skip to content
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
5 changes: 3 additions & 2 deletions polygon/rest/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ class RESTClient:
""" This is a custom generated class """
DEFAULT_HOST = "api.polygon.io"

def __init__(self, auth_key: str):
def __init__(self, auth_key: str, timeout: int=None):
self.auth_key = auth_key
self.url = "https://" + self.DEFAULT_HOST

self._session = requests.Session()
self._session.params["apiKey"] = self.auth_key
self.timeout = timeout

def __enter__(self):
return self
Expand All @@ -27,7 +28,7 @@ def close(self):
self._session.close()

def _handle_response(self, response_type: str, endpoint: str, params: Dict[str, str]) -> Type[models.AnyDefinition]:
resp: requests.Response = self._session.get(endpoint, params=params)
resp: requests.Response = self._session.get(endpoint, params=params, timeout=self.timeout)
if resp.status_code == 200:
return unmarshal.unmarshal_json(response_type, resp.json())
else:
Expand Down