STINNER Victor added the comment:
The PEP 446 partially fixes this issue. The issue #19764 should fix it
completly. Since you are using Python 2, you should not wait until the issue is
fixed, but work around it.
To workaround the issue: use you own lock around the creation of processes.
Example:
---
lock = threading.Lock()
...
def run_command(...):
with lock:
proc = subprocess.Popen(...)
return proc.communicate()
---
The problem is that a thread B may inherit the handle of a pipe from handle A
because the pip is marked as inheritable, and the subprocess module must use
CreateProcess() with bInheritHandles parameter set to True to be able to
redirect stdout.
Said differently: the subprocess is not thread-safe, you have to use your own
lock to workaround race conditions.
----------
nosy: +haypo, sbt
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue12739>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com