[Python-checkins] gh-104340: Suppress warning about unawaited exception for closed pipe stdin (#104586)

gvanrossum webhook-mailer at python.org
Wed May 17 19:45:18 EDT 2023


https://github.com/python/cpython/commit/7fc8e2d4627cdba5cb0075c9052ed6f4b6ecd36d
commit: 7fc8e2d4627cdba5cb0075c9052ed6f4b6ecd36d
branch: main
author: Guido van Rossum <guido at python.org>
committer: gvanrossum <gvanrossum at gmail.com>
date: 2023-05-17T16:45:11-07:00
summary:

gh-104340: Suppress warning about unawaited exception for closed pipe stdin (#104586)

files:
A Misc/NEWS.d/next/Library/2023-05-17-20-03-01.gh-issue-104340.kp_XmX.rst
M Lib/asyncio/subprocess.py

diff --git a/Lib/asyncio/subprocess.py b/Lib/asyncio/subprocess.py
index 50727ca300e6..c4e5ba2061cf 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
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 000000000000..5b03622df6a2
--- /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").



More information about the Python-checkins mailing list