From ad0dbba018c83c0643c131e1095aa9fb3257049b Mon Sep 17 00:00:00 2001 From: beavailable Date: Thu, 26 Jan 2023 08:50:25 +0800 Subject: [PATCH 1/5] gh-101317: Add ssl_shutdown_timeout parameter for StreamWriter.start_tls() --- Lib/asyncio/streams.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Lib/asyncio/streams.py b/Lib/asyncio/streams.py index 0f9098b4195633..7d13e961bd2de4 100644 --- a/Lib/asyncio/streams.py +++ b/Lib/asyncio/streams.py @@ -378,7 +378,8 @@ async def drain(self): 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 @@ async def start_tls(self, sslcontext, *, 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) From 44dcb5a860fe24a47298c381f316dfdb43fccfe2 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Thu, 26 Jan 2023 01:25:57 +0000 Subject: [PATCH 2/5] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../next/Library/2023-01-26-01-25-56.gh-issue-101317.vWaS1x.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Library/2023-01-26-01-25-56.gh-issue-101317.vWaS1x.rst 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 00000000000000..ac930e0f03758c --- /dev/null +++ b/Misc/NEWS.d/next/Library/2023-01-26-01-25-56.gh-issue-101317.vWaS1x.rst @@ -0,0 +1 @@ +Add ``ssl_shutdown_timeout`` parameter for ``StreamWriter.start_tls()``. From 19b6e9a50beeecce8b07c32de18aac5a1e6ff77f Mon Sep 17 00:00:00 2001 From: beavailable Date: Wed, 1 Feb 2023 09:36:56 +0800 Subject: [PATCH 3/5] Add Docs --- Doc/library/asyncio-stream.rst | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Doc/library/asyncio-stream.rst b/Doc/library/asyncio-stream.rst index c1ae8abb9abcd5..533bdec8e03993 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 From a892d514655af61db612e49c359ea2de3aba1457 Mon Sep 17 00:00:00 2001 From: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> Date: Wed, 1 Feb 2023 15:58:57 +0530 Subject: [PATCH 4/5] Update Misc/NEWS.d/next/Library/2023-01-26-01-25-56.gh-issue-101317.vWaS1x.rst --- .../Library/2023-01-26-01-25-56.gh-issue-101317.vWaS1x.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 index ac930e0f03758c..f661abeb523956 100644 --- 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 @@ -1 +1,2 @@ -Add ``ssl_shutdown_timeout`` parameter for ``StreamWriter.start_tls()``. +Add *ssl_shutdown_timeout* parameter for :meth:`asyncio.StreamWriter.start_tls()`. + From e5da8f00a6b4f04df222de86acc5d38f8226a3fc Mon Sep 17 00:00:00 2001 From: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> Date: Wed, 1 Feb 2023 16:02:58 +0530 Subject: [PATCH 5/5] Update Misc/NEWS.d/next/Library/2023-01-26-01-25-56.gh-issue-101317.vWaS1x.rst --- .../next/Library/2023-01-26-01-25-56.gh-issue-101317.vWaS1x.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index f661abeb523956..f1ce0e0a527661 100644 --- 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 @@ -1,2 +1,2 @@ -Add *ssl_shutdown_timeout* parameter for :meth:`asyncio.StreamWriter.start_tls()`. +Add *ssl_shutdown_timeout* parameter for :meth:`asyncio.StreamWriter.start_tls`.