Skip to content
This repository was archived by the owner on Mar 6, 2026. It is now read-only.

Commit 952a407

Browse files
chore: Add try catch block for exceptions if returned from configure_mtls_channel
Signed-off-by: Radhika Agrawal <agrawalradhika@google.com>
1 parent 29b9625 commit 952a407

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

google/auth/aio/transport/sessions.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,14 @@ async def request(
264264
`timeout`.
265265
"""
266266
if self._mtls_init_task:
267-
await self._mtls_init_task
267+
try:
268+
await self._mtls_init_task
269+
except exceptions.MutualTLSChannelError:
270+
# Re-raise the already-wrapped mTLS error
271+
raise
272+
except Exception as caught_exc:
273+
# Wrap any other unexpected exceptions from the task
274+
raise exceptions.MutualTLSChannelError(caught_exc) from caught_exc
268275
retries = _exponential_backoff.AsyncExponentialBackoff(
269276
total_attempts=total_attempts,
270277
)
@@ -278,7 +285,7 @@ async def request(
278285
)
279286
)
280287
actual_timeout: float = 0.0
281-
if isinstance(timeout, aiohttp.ClientTimeout):
288+
if ClientTimeout is not None and isinstance(timeout, aiohttp.ClientTimeout):
282289
actual_timeout = timeout.total if timeout.total is not None else 0.0
283290
elif isinstance(timeout, (int, float)):
284291
actual_timeout = float(timeout)

0 commit comments

Comments
 (0)