Skip to content

Commit

Permalink
Fixed timeouts in case of https connection establishing
Browse files Browse the repository at this point in the history
  • Loading branch information
cdeler committed Nov 13, 2020
1 parent db81ed0 commit 7836199
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions httpcore/_backends/asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,18 @@ async def start_tls(

loop_start_tls = getattr(loop, "start_tls", backport_start_tls)

transport = await asyncio.wait_for(
loop_start_tls(
transport,
protocol,
ssl_context,
server_hostname=hostname.decode("ascii"),
),
timeout=timeout.get("connect"),
)
exc_map = {asyncio.TimeoutError: ConnectTimeout, OSError: ConnectError}

with map_exceptions(exc_map):
transport = await asyncio.wait_for(
loop_start_tls(
transport,
protocol,
ssl_context,
server_hostname=hostname.decode("ascii"),
),
timeout=timeout.get("connect"),
)

stream_reader.set_transport(transport)
stream_writer = asyncio.StreamWriter(
Expand Down

0 comments on commit 7836199

Please sign in to comment.