Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
gh-142489: Increase ssl_handshake_timeout in asyncio tests (GH-142523)
Replace SHORT_TIMEOUT with LONG_TIMEOUT for very slow CIs.
And add the HANDSHAKE_TIMEOUT constant.
(cherry picked from commit dc3ece2)

Co-authored-by: Victor Stinner <[email protected]>
  • Loading branch information
vstinner authored and miss-islington committed Dec 10, 2025
commit 3ae2376fc331f1750a35b466292c2dda0017026a
40 changes: 17 additions & 23 deletions Lib/test/test_asyncio/test_ssl.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

MACOS = (sys.platform == 'darwin')
BUF_MULTIPLIER = 1024 if not MACOS else 64
HANDSHAKE_TIMEOUT = support.LONG_TIMEOUT


def tearDownModule():
Expand Down Expand Up @@ -257,15 +258,12 @@ def prog(sock):
await fut

async def start_server():
extras = {}
extras = dict(ssl_handshake_timeout=support.SHORT_TIMEOUT)

srv = await asyncio.start_server(
handle_client,
'127.0.0.1', 0,
family=socket.AF_INET,
ssl=sslctx,
**extras)
ssl_handshake_timeout=HANDSHAKE_TIMEOUT)

try:
srv_socks = srv.sockets
Expand Down Expand Up @@ -322,14 +320,11 @@ def server(sock):
sock.close()

async def client(addr):
extras = {}
extras = dict(ssl_handshake_timeout=support.SHORT_TIMEOUT)

reader, writer = await asyncio.open_connection(
*addr,
ssl=client_sslctx,
server_hostname='',
**extras)
ssl_handshake_timeout=HANDSHAKE_TIMEOUT)

writer.write(A_DATA)
self.assertEqual(await reader.readexactly(2), b'OK')
Expand All @@ -349,7 +344,8 @@ async def client_sock(addr):
reader, writer = await asyncio.open_connection(
sock=sock,
ssl=client_sslctx,
server_hostname='')
server_hostname='',
ssl_handshake_timeout=HANDSHAKE_TIMEOUT)

writer.write(A_DATA)
self.assertEqual(await reader.readexactly(2), b'OK')
Expand Down Expand Up @@ -448,7 +444,7 @@ async def client(addr):
*addr,
ssl=client_sslctx,
server_hostname='',
ssl_handshake_timeout=support.SHORT_TIMEOUT)
ssl_handshake_timeout=HANDSHAKE_TIMEOUT)
writer.close()
await self.wait_closed(writer)

Expand Down Expand Up @@ -610,7 +606,7 @@ def client():

extras = {}
if server_ssl:
extras = dict(ssl_handshake_timeout=support.SHORT_TIMEOUT)
extras = dict(ssl_handshake_timeout=HANDSHAKE_TIMEOUT)

f = loop.create_task(
loop.connect_accepted_socket(
Expand Down Expand Up @@ -659,7 +655,8 @@ async def client(addr):
reader, writer = await asyncio.open_connection(
*addr,
ssl=client_sslctx,
server_hostname='')
server_hostname='',
ssl_handshake_timeout=HANDSHAKE_TIMEOUT)

self.assertEqual(await reader.readline(), b'A\n')
writer.write(b'B')
Expand Down Expand Up @@ -1152,14 +1149,11 @@ def do(func, *args):
await fut

async def start_server():
extras = {}

srv = await self.loop.create_server(
server_protocol_factory,
'127.0.0.1', 0,
family=socket.AF_INET,
ssl=sslctx_1,
**extras)
ssl=sslctx_1)

try:
srv_socks = srv.sockets
Expand Down Expand Up @@ -1209,14 +1203,11 @@ def server(sock):
sock.close()

async def client(addr):
extras = {}
extras = dict(ssl_handshake_timeout=support.SHORT_TIMEOUT)

reader, writer = await asyncio.open_connection(
*addr,
ssl=client_sslctx,
server_hostname='',
**extras)
ssl_handshake_timeout=HANDSHAKE_TIMEOUT)

writer.write(A_DATA)
self.assertEqual(await reader.readexactly(2), b'OK')
Expand Down Expand Up @@ -1286,7 +1277,8 @@ async def client(addr):
reader, writer = await asyncio.open_connection(
*addr,
ssl=client_sslctx,
server_hostname='')
server_hostname='',
ssl_handshake_timeout=HANDSHAKE_TIMEOUT)
sslprotocol = writer.transport._ssl_protocol
writer.write(b'ping')
data = await reader.readexactly(4)
Expand Down Expand Up @@ -1398,7 +1390,8 @@ async def client(addr):
reader, writer = await asyncio.open_connection(
*addr,
ssl=client_sslctx,
server_hostname='')
server_hostname='',
ssl_handshake_timeout=HANDSHAKE_TIMEOUT)
writer.write(b'ping')
data = await reader.readexactly(4)
self.assertEqual(data, b'pong')
Expand Down Expand Up @@ -1529,7 +1522,8 @@ async def client(addr):
reader, writer = await asyncio.open_connection(
*addr,
ssl=client_sslctx,
server_hostname='')
server_hostname='',
ssl_handshake_timeout=HANDSHAKE_TIMEOUT)
writer.write(b'ping')
data = await reader.readexactly(4)
self.assertEqual(data, b'pong')
Expand Down
Loading