Skip to content

Commit 7fc8e2d

Browse files
authored
pythongh-104340: Suppress warning about unawaited exception for closed pipe stdin (python#104586)
1 parent b27fe67 commit 7fc8e2d

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

Lib/asyncio/subprocess.py

+3
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
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)