Skip to content

Commit 3791368

Browse files
author
Uziel Silva
committed
feat: Pass loop to aiohttp client
1 parent f8391aa commit 3791368

File tree

3 files changed

+4
-6
lines changed

3 files changed

+4
-6
lines changed

google/cloud/sql/connector/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ def __init__(
5858
client: Optional[aiohttp.ClientSession] = None,
5959
driver: Optional[str] = None,
6060
user_agent: Optional[str] = None,
61+
loop: Optional[asyncio.AbstractEventLoop] = None,
6162
) -> None:
6263
"""Establishes the client to be used for Cloud SQL Admin API requests.
6364
@@ -84,8 +85,7 @@ def __init__(
8485
}
8586
if quota_project:
8687
headers["x-goog-user-project"] = quota_project
87-
88-
self._client = client if client else aiohttp.ClientSession(headers=headers)
88+
self._client = client if client else aiohttp.ClientSession(headers=headers, loop=loop)
8989
self._credentials = credentials
9090
if sqladmin_api_endpoint is None:
9191
self._sqladmin_api_endpoint = DEFAULT_SERVICE_ENDPOINT

google/cloud/sql/connector/connector.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ def _init_client(self, driver: Optional[str]) -> CloudSQLClient:
363363
self._credentials,
364364
user_agent=self._user_agent,
365365
driver=driver,
366+
loop=self._loop
366367
)
367368
return self._client
368369

@@ -419,6 +420,7 @@ async def connect_async(
419420
self._credentials,
420421
user_agent=self._user_agent,
421422
driver=driver,
423+
loop=self._loop
422424
)
423425
enable_iam_auth = kwargs.pop("enable_iam_auth", self._enable_iam_auth)
424426

tests/system/test_psycopg_connection.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,6 @@ async def test_psycopg_connection() -> None:
5858
await connector.start_unix_socket_proxy_async(
5959
instance_connection_name,
6060
unix_socket_path,
61-
driver="psycopg",
62-
user=user,
63-
password=password,
64-
db=db,
6561
ip_type=ip_type, # can be "public", "private" or "psc"
6662
)
6763

0 commit comments

Comments
 (0)