Skip to content

Commit 75f4ca9

Browse files
Uziel Silvathameezb
authored andcommitted
feat: Pass loop to aiohttp client
1 parent 7cd74a5 commit 75f4ca9

3 files changed

Lines changed: 4 additions & 6 deletions

File tree

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
@@ -371,6 +371,7 @@ def _init_client(self, driver: Optional[str]) -> CloudSQLClient:
371371
self._credentials,
372372
user_agent=self._user_agent,
373373
driver=driver,
374+
loop=self._loop
374375
)
375376
return self._client
376377

@@ -432,6 +433,7 @@ async def connect_async(
432433
self._credentials,
433434
user_agent=self._user_agent,
434435
driver=driver,
436+
loop=self._loop
435437
)
436438
enable_iam_auth = kwargs.pop("enable_iam_auth", self._enable_iam_auth)
437439

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)