On Ubuntu 10.10 amd64 and dual-core CPU, following code deadlocks.
What's wrong on this code?

#http://codepad.org/GkoXHbik

#!/usr/bin/env python

from subprocess import *
from threading import *

THREAD_COUNT=50

def worker():
    p = Popen(["cat"], stdin=PIPE, stdout=PIPE, stderr=STDOUT)
    out = p.communicate("hoge")[0]
    print "%s %s" % (current_thread().name, out)

threads = []
for i in range(THREAD_COUNT):
    threads.append(Thread(target=worker, name=str(i)))
for t in threads: t.start()
for t in threads: t.join()

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to