T
Toon Verstraelen
Hi,
I recently had a thread problem and I could reduce it to a very short
example that shows the problem. I hope it has its origin in my
misunderstanding of how python threads work. Here it is:
--- my_thread.py ---
import threading
from subprocess import Popen, PIPE, STDOUT
class MyThread(threading.Thread):
def run(self):
print "before Popen"
sp = Popen(["ls", "-al"], stdout=PIPE, stderr=STDOUT)
print "before first line"
for line in sp.stdout:
print line[:-1]
print "after last line"
t = MyThread()
t.start()
--- main.py ---
import my_thread
----------------
If I start my_thread.py directly there is no problem, but when i run
'python main.py' the thread hangs on the creation of the Popen object. I'm
using python 2.4.2 on gentoo linux. Can someone reproduce the problem?
Thanks for reading this.
Toon
I recently had a thread problem and I could reduce it to a very short
example that shows the problem. I hope it has its origin in my
misunderstanding of how python threads work. Here it is:
--- my_thread.py ---
import threading
from subprocess import Popen, PIPE, STDOUT
class MyThread(threading.Thread):
def run(self):
print "before Popen"
sp = Popen(["ls", "-al"], stdout=PIPE, stderr=STDOUT)
print "before first line"
for line in sp.stdout:
print line[:-1]
print "after last line"
t = MyThread()
t.start()
--- main.py ---
import my_thread
----------------
If I start my_thread.py directly there is no problem, but when i run
'python main.py' the thread hangs on the creation of the Popen object. I'm
using python 2.4.2 on gentoo linux. Can someone reproduce the problem?
Thanks for reading this.
Toon