You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
More details [here](https://cloud.google.com/vertex-ai/generative-ai/docs/learn/locations#genai-locations).
186
183
"""
187
-
188
-
189
-
class_SafelyClosingClient(Client):
190
-
@staticmethod
191
-
def_get_api_client(
192
-
vertexai: bool|None=None,
193
-
api_key: str|None=None,
194
-
credentials: Credentials|None=None,
195
-
project: str|None=None,
196
-
location: str|None=None,
197
-
debug_config: DebugConfig|None=None,
198
-
http_options: HttpOptions|None=None,
199
-
) ->BaseApiClient:
200
-
return_NonClosingApiClient(
201
-
vertexai=vertexai,
202
-
api_key=api_key,
203
-
credentials=credentials,
204
-
project=project,
205
-
location=location,
206
-
http_options=http_options,
207
-
)
208
-
209
-
defclose(self) ->None:
210
-
# This is called from `Client.__del__`, even if `Client.__init__` raised an error before `self._api_client` is set, which would raise an `AttributeError` here.
211
-
# TODO: Remove once https://github.com/googleapis/python-genai/issues/1567 is solved.
212
-
try:
213
-
super().close()
214
-
exceptAttributeError:
215
-
pass
216
-
217
-
218
-
class_NonClosingApiClient(BaseApiClient):
219
-
asyncdefaclose(self) ->None:
220
-
# The original implementation also calls `await self._async_httpx_client.aclose()`, but we don't want to close our `cached_async_http_client` or the one the user passed in.
221
-
# TODO: Remove once https://github.com/googleapis/python-genai/issues/1566 is solved.
222
-
ifself._aiohttp_session:
223
-
awaitself._aiohttp_session.close() # pragma: no cover
0 commit comments