Duane Griffin <dua...@dghda.com> added the comment:

I can reproduce this on Windows 10 with Python 3.9. See attached source. At 
least for us, it is hanging when one thread is doing a read on the file 
descriptor while a second calls Py_Initialize (or just dup directly).

The windows kernel call stack shows the dup call is waiting on a critical 
section, while the thread reading from stdin is waiting in ReadFile. I can get 
a full stack trace from WinDbg if it is helpful, but hopefully the attached 
code should be enough to reproduce the problem at will for anyone interested.

If stdin is receiving input, or is closed, then the read call will complete and 
unblock dup in due course. However if not then it will hang indefinitely.

If we can fix this to work reliably in Python that would be great. Otherwise, 
or in the meantime, we could just add a note to the documentation. We are going 
to try and work-around it by using a different file descriptor instead of 
stdin. Other applications might be able to avoid IO using stdin until after 
python is initialised.

----------
nosy: +duaneg
Added file: https://bugs.python.org/file50099/dup-hang.c

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

Reply via email to