summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbeavailable <beavailable@proton.me>2023-02-01 11:03:59 (GMT)
committerGitHub <noreply@github.com>2023-02-01 11:03:59 (GMT)
commitcc407b9de645ab7c137df8ea2409a005369169a5 (patch)
treec2df6b351a04a56153016e535f34f8f99b7a4724
parent75227fba1dd1683289d90ada7abba237bff55d14 (diff)
downloadcpython-cc407b9de645ab7c137df8ea2409a005369169a5.zip
cpython-cc407b9de645ab7c137df8ea2409a005369169a5.tar.gz
cpython-cc407b9de645ab7c137df8ea2409a005369169a5.tar.bz2
gh-101317: Add `ssl_shutdown_timeout` parameter for `asyncio.StreamWriter.start_tls` (#101335)
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
-rw-r--r--Doc/library/asyncio-stream.rst10
-rw-r--r--Lib/asyncio/streams.py6
-rw-r--r--Misc/NEWS.d/next/Library/2023-01-26-01-25-56.gh-issue-101317.vWaS1x.rst2
3 files changed, 15 insertions, 3 deletions
diff --git a/Doc/library/asyncio-stream.rst b/Doc/library/asyncio-stream.rst
index c1ae8ab..533bdec 100644
--- a/Doc/library/asyncio-stream.rst
+++ b/Doc/library/asyncio-stream.rst
@@ -335,7 +335,7 @@ StreamWriter
returns immediately.
.. coroutinemethod:: start_tls(sslcontext, \*, server_hostname=None, \
- ssl_handshake_timeout=None)
+ ssl_handshake_timeout=None, ssl_shutdown_timeout=None)
Upgrade an existing stream-based connection to TLS.
@@ -350,8 +350,16 @@ StreamWriter
handshake to complete before aborting the connection. ``60.0`` seconds
if ``None`` (default).
+ * *ssl_shutdown_timeout* is the time in seconds to wait for the SSL shutdown
+ to complete before aborting the connection. ``30.0`` seconds if ``None``
+ (default).
+
.. versionadded:: 3.11
+ .. versionchanged:: 3.12
+ Added the *ssl_shutdown_timeout* parameter.
+
+
.. method:: is_closing()
Return ``True`` if the stream is closed or in the process of
diff --git a/Lib/asyncio/streams.py b/Lib/asyncio/streams.py
index 0f9098b..7d13e96 100644
--- a/Lib/asyncio/streams.py
+++ b/Lib/asyncio/streams.py
@@ -378,7 +378,8 @@ class StreamWriter:
async def start_tls(self, sslcontext, *,
server_hostname=None,
- ssl_handshake_timeout=None):
+ ssl_handshake_timeout=None,
+ ssl_shutdown_timeout=None):
"""Upgrade an existing stream-based connection to TLS."""
server_side = self._protocol._client_connected_cb is not None
protocol = self._protocol
@@ -386,7 +387,8 @@ class StreamWriter:
new_transport = await self._loop.start_tls( # type: ignore
self._transport, protocol, sslcontext,
server_side=server_side, server_hostname=server_hostname,
- ssl_handshake_timeout=ssl_handshake_timeout)
+ ssl_handshake_timeout=ssl_handshake_timeout,
+ ssl_shutdown_timeout=ssl_shutdown_timeout)
self._transport = new_transport
protocol._replace_writer(self)
diff --git a/Misc/NEWS.d/next/Library/2023-01-26-01-25-56.gh-issue-101317.vWaS1x.rst b/Misc/NEWS.d/next/Library/2023-01-26-01-25-56.gh-issue-101317.vWaS1x.rst
new file mode 100644
index 0000000..f1ce0e0
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2023-01-26-01-25-56.gh-issue-101317.vWaS1x.rst
@@ -0,0 +1,2 @@
+Add *ssl_shutdown_timeout* parameter for :meth:`asyncio.StreamWriter.start_tls`.
+