Message220096
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. |
|
Date |
User |
Action |
Args |
2014-06-09 14:36:08 | vstinner | set | recipients:
+ vstinner, gjb1002, sbt, SAPikachu |
2014-06-09 14:36:08 | vstinner | set | messageid: <1402324568.77.0.241930681746.issue12739@psf.upfronthosting.co.za> |
2014-06-09 14:36:08 | vstinner | link | issue12739 messages |
2014-06-09 14:36:08 | vstinner | create | |
|