Skip to content

Commit cc407b9

Browse files
gh-101317: Add ssl_shutdown_timeout parameter for asyncio.StreamWriter.start_tls (#101335)
Co-authored-by: Kumar Aditya <[email protected]>
1 parent 75227fb commit cc407b9

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

Doc/library/asyncio-stream.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ StreamWriter
335335
returns immediately.
336336

337337
.. coroutinemethod:: start_tls(sslcontext, \*, server_hostname=None, \
338-
ssl_handshake_timeout=None)
338+
ssl_handshake_timeout=None, ssl_shutdown_timeout=None)
339339

340340
Upgrade an existing stream-based connection to TLS.
341341

@@ -350,8 +350,16 @@ StreamWriter
350350
handshake to complete before aborting the connection. ``60.0`` seconds
351351
if ``None`` (default).
352352

353+
* *ssl_shutdown_timeout* is the time in seconds to wait for the SSL shutdown
354+
to complete before aborting the connection. ``30.0`` seconds if ``None``
355+
(default).
356+
353357
.. versionadded:: 3.11
354358

359+
.. versionchanged:: 3.12
360+
Added the *ssl_shutdown_timeout* parameter.
361+
362+
355363
.. method:: is_closing()
356364

357365
Return ``True`` if the stream is closed or in the process of

Lib/asyncio/streams.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,15 +378,17 @@ async def drain(self):
378378

379379
async def start_tls(self, sslcontext, *,
380380
server_hostname=None,
381-
ssl_handshake_timeout=None):
381+
ssl_handshake_timeout=None,
382+
ssl_shutdown_timeout=None):
382383
"""Upgrade an existing stream-based connection to TLS."""
383384
server_side = self._protocol._client_connected_cb is not None
384385
protocol = self._protocol
385386
await self.drain()
386387
new_transport = await self._loop.start_tls( # type: ignore
387388
self._transport, protocol, sslcontext,
388389
server_side=server_side, server_hostname=server_hostname,
389-
ssl_handshake_timeout=ssl_handshake_timeout)
390+
ssl_handshake_timeout=ssl_handshake_timeout,
391+
ssl_shutdown_timeout=ssl_shutdown_timeout)
390392
self._transport = new_transport
391393
protocol._replace_writer(self)
392394

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Add *ssl_shutdown_timeout* parameter for :meth:`asyncio.StreamWriter.start_tls`.
2+

0 commit comments

Comments
 (0)