]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-104340: Suppress warning about unawaited exception for closed pipe stdin (#104586)
authorGuido van Rossum <guido@python.org>
Wed, 17 May 2023 23:45:11 +0000 (16:45 -0700)
committerGitHub <noreply@github.com>
Wed, 17 May 2023 23:45:11 +0000 (16:45 -0700)
Lib/asyncio/subprocess.py
Misc/NEWS.d/next/Library/2023-05-17-20-03-01.gh-issue-104340.kp_XmX.rst [new file with mode: 0644]

index 50727ca300e63ea5a5bda456475f4d95577a7b48..c4e5ba2061cffc80b95c4832735186f0eebf9001 100644 (file)
@@ -81,6 +81,9 @@ class SubprocessStreamProtocol(streams.FlowControlMixin,
                 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 (file)
index 0000000..5b03622
--- /dev/null
@@ -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").