From 55d7498bfa1056b0dfa6e002f6898b8be14a46e6 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Wed, 17 May 2023 12:44:59 -0700 Subject: [PATCH 1/2] Suppress warning about unawaited exception for closed pipe stdin --- Lib/asyncio/subprocess.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Lib/asyncio/subprocess.py b/Lib/asyncio/subprocess.py index 50727ca300e63e..c4e5ba2061cffc 100644 --- a/Lib/asyncio/subprocess.py +++ b/Lib/asyncio/subprocess.py @@ -81,6 +81,9 @@ def pipe_connection_lost(self, fd, exc): self._stdin_closed.set_result(None) else: self._stdin_closed.set_exception(exc) + # Since calling `wait_closed()` is not mandatory, + # we shouldn't log the traceback if this is not awaited. + self._stdin_closed._log_traceback = False return if fd == 1: reader = self.stdout From ac87d67d5498994a1b3731b7d237946a5bc9e1e4 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Wed, 17 May 2023 20:03:07 +0000 Subject: [PATCH 2/2] =?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-05-17-20-03-01.gh-issue-104340.kp_XmX.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Library/2023-05-17-20-03-01.gh-issue-104340.kp_XmX.rst diff --git a/Misc/NEWS.d/next/Library/2023-05-17-20-03-01.gh-issue-104340.kp_XmX.rst b/Misc/NEWS.d/next/Library/2023-05-17-20-03-01.gh-issue-104340.kp_XmX.rst new file mode 100644 index 00000000000000..5b03622df6a2ab --- /dev/null +++ b/Misc/NEWS.d/next/Library/2023-05-17-20-03-01.gh-issue-104340.kp_XmX.rst @@ -0,0 +1 @@ +When an ``asyncio`` pipe protocol loses its connection due to an error, and the caller doesn't await ``wait_closed()`` on the corresponding ``StreamWriter``, don't log a warning about an exception that was never retrieved. After all, according to the ``StreamWriter.close()`` docs, the ``wait_closed()`` call is optional ("not mandatory").