New submission from William Fisher <william.w.fis...@gmail.com>:

I have a reproducible case where stdin.wait_closed() is hanging on
Windows. This happens in response to a BrokenPipeError. The same code 
works fine on Linux and MacOS.

Please see the attached code for the demo.

I believe the hang is related to this debug message from the logs:


DEBUG <_ProactorWritePipeTransport closing fd=632>: Fatal write error on pipe 
transport
Traceback (most recent call last):
  File 
"C:\hostedtoolcache\windows\Python\3.9.6\x64\lib\asyncio\proactor_events.py", 
line 379, in _loop_writing
    f.result()
  File 
"C:\hostedtoolcache\windows\Python\3.9.6\x64\lib\asyncio\windows_events.py", 
line 812, in _poll
    value = callback(transferred, key, ov)
  File 
"C:\hostedtoolcache\windows\Python\3.9.6\x64\lib\asyncio\windows_events.py", 
line 538, in finish_send
    return ov.getresult()
BrokenPipeError: [WinError 109] The pipe has been ended


It appears that the function that logs "Fatal write error on pipe transport" 
also 
calls _abort on the stream. If _abort is called before stdin.close(), 
everything is okay. 
If _abort is called after stdin.close(), stdin.wait_closed() will hang.

Please see issue #44428 for another instance of a similar hang in wait_closed().

----------
components: asyncio
files: wait_closed.py
messages: 400810
nosy: asvetlov, byllyfish, yselivanov
priority: normal
severity: normal
status: open
title: asyncio hang in subprocess wait_closed() on Windows, BrokenPipeError
type: behavior
versions: Python 3.10, Python 3.9
Added file: https://bugs.python.org/file50250/wait_closed.py

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue45074>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to