Skip to content

Commit a93b3c0

Browse files
authored
feat: allow passings requests session (#414)
1 parent 891321c commit a93b3c0

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

googlemaps/client.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ def __init__(self, key=None, client_id=None, client_secret=None,
5454
retry_timeout=60, requests_kwargs=None,
5555
queries_per_second=50, channel=None,
5656
retry_over_query_limit=True, experience_id=None,
57+
requests_session=None,
5758
base_url=_DEFAULT_BASE_URL):
5859
"""
5960
:param key: Maps API key. Required, unless "client_id" and
@@ -116,6 +117,9 @@ def __init__(self, key=None, client_id=None, client_secret=None,
116117
implemented. See the official requests docs for more info:
117118
http://docs.python-requests.org/en/latest/api/#main-interface
118119
:type requests_kwargs: dict
120+
121+
:param requests_session: Reused persistent session for flexibility.
122+
:type requests_session: requests.Session
119123
120124
:param base_url: The base URL for all requests. Defaults to the Maps API
121125
server. Should not have a trailing slash.
@@ -136,7 +140,7 @@ def __init__(self, key=None, client_id=None, client_secret=None,
136140
"and hyphen (-) characters are allowed. If used without "
137141
"client_id, it must be 0-999.")
138142

139-
self.session = requests.Session()
143+
self.session = requests_session or requests.Session()
140144
self.key = key
141145

142146
if timeout and (connect_timeout or read_timeout):

0 commit comments

Comments
 (0)