New submission from Ludwig Hähne <[EMAIL PROTECTED]>: Pythons subprocess module has a race condition when stdin is used. The problem can be reproduced with the following script (based on the script in issue "#1731717"/"msg32210" (slightly changed to use stdin):
---- import sys, os, threading, subprocess, time class X(threading.Thread): def __init__(self, *args, **kwargs): super(X, self).__init__(*args, **kwargs) self.start() def tt(): s = subprocess.Popen(("cat"), stdin=subprocess.PIPE) s.communicate(input = '#') for i in xrange(20): X(target = tt) ---- On multi-processor (or multi-core) machines the script hangs fairly reliably. Protecting the Popen call with a lock solves the problem. I searched the documentation if using stdin with subprocess.Popen was not thread-safe, but found no indication. Tested with Python 2.5.1, 2.5.2 and 2.6a1. The problem can be reproduced with all mentioned versions. ---------- components: Library (Lib) messages: 63637 nosy: Pankrat severity: normal status: open title: Race condition in subprocess using stdin versions: Python 2.5, Python 2.6 __________________________________ Tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue2320> __________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com