Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a8fc8b7

Browse files
[3.11] gh-104340: Suppress warning about unawaited exception for closed pipe stdin (GH-104586) (#104594)
(cherry picked from commit 7fc8e2d) Co-authored-by: Guido van Rossum <[email protected]>
1 parent 610cc0a commit a8fc8b7

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

Lib/asyncio/subprocess.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ def pipe_connection_lost(self, fd, exc):
8181
self._stdin_closed.set_result(None)
8282
else:
8383
self._stdin_closed.set_exception(exc)
84+
# Since calling `wait_closed()` is not mandatory,
85+
# we shouldn't log the traceback if this is not awaited.
86+
self._stdin_closed._log_traceback = False
8487
return
8588
if fd == 1:
8689
reader = self.stdout
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
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").

0 commit comments

Comments
 (0)