[issue1336] subprocess.Popen hangs when child writes to stderr

john doe report at bugs.python.org
Mon Oct 31 11:22:44 CET 2011


john doe <tnagy1024 at gmail.com> added the comment:

The following piece of code does not seem to be thread-safe:

gc.disable()
try:
    os.fork()
except:
    ...

If calling subprocess.Popen() is supposed to work from threads without any particular protection, then a lock is needed in subprocess.py:

try:
   spawn_lock.acquire()
   gc.disable()
   try:
       os.fork()
   except:
       ...
finally:
   spawn_lock.release()

Such issues are very difficult to reproduce and to track. The documentation should at least mention that calling gc.enable() may cause subprocess() to hang!

The following issue seems to be relevant: http://bugs.python.org/issue12739

----------
nosy: +ita1024

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue1336>
_______________________________________


More information about the Python-bugs-list mailing list