Skip to content

Commit b663bbe

Browse files
Uziel Silvathameezb
authored andcommitted
fix(main): Add support for Python 3.9
1 parent 1974df5 commit b663bbe

3 files changed

Lines changed: 9 additions & 9 deletions

File tree

google/cloud/sql/connector/connector.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -537,18 +537,12 @@ async def close_async(self) -> None:
537537
"""Helper function to cancel the cache's tasks
538538
and close aiohttp.ClientSession."""
539539
self._closed = True
540+
if self._proxies:
541+
await asyncio.gather(*[proxy.close() for proxy in self._proxies])
540542
if self._client:
541543
await self._client.close()
542-
if self._proxy:
543-
proxy_task = asyncio.gather(self._proxy)
544-
try:
545-
await asyncio.wait_for(proxy_task, timeout=0.1)
546-
except TimeoutError:
547-
# This task runs forever so it is expected to raise this exception
548-
pass
549544
await asyncio.gather(*[cache.close() for cache in self._cache.values()])
550545

551-
552546
async def create_async_connector(
553547
ip_type: str | IPTypes = IPTypes.PUBLIC,
554548
enable_iam_auth: bool = False,

tests/unit/test_connector.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,12 @@ async def test_Connector_connect_local_proxy(
321321
mock_connect.assert_called_once()
322322
mock_proxy.assert_called_once()
323323
assert connection is True
324+
325+
proxy_task = asyncio.gather(task)
326+
try:
327+
await asyncio.wait_for(proxy_task, timeout=0.1)
328+
except (asyncio.CancelledError, asyncio.TimeoutError, TimeoutError):
329+
pass # This task runs forever so it is expected to throw this exception
324330

325331

326332
@pytest.mark.asyncio

tests/unit/test_proxy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ async def test_proxy_creates_folder(context: ssl.SSLContext, kwargs: Any) -> Non
4444
proxy_task = asyncio.gather(task)
4545
try:
4646
await asyncio.wait_for(proxy_task, timeout=0.1)
47-
except TimeoutError:
47+
except (asyncio.CancelledError, asyncio.TimeoutError, TimeoutError):
4848
pass # This task runs forever so it is expected to throw this exception
4949

5050
@pytest.mark.usefixtures("proxy_server")

0 commit comments

Comments
 (0)