I'm having problems calling the Popen4 object wait() method
from a thread. The folloing program produces an error on some
machines (but seems to work on others)
------------------------------8<------------------------------
import time
import threading
import popen2
def monitorThread() :
while True:
s = p.fromchild.rea dline()
if s:
print s
else:
print p.wait()
watching = False
break
watching = True
p = popen2.Popen4(' mplayer -quiet -slave test.avi')
threading.Threa d(target=monito rThread).start( )
while watching:
time.sleep(0.1)
------------------------------8<------------------------------
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python2.4/threading.py", line 442, in __bootstrap
self.run()
File "/usr/lib/python2.4/threading.py", line 422, in run
self.__target(* self.__args, **self.__kwargs )
File "testit.py" , line 11, in monitorThread
print p.wait()
File "/usr/lib/python2.4/popen2.py", line 94, in wait
pid, sts = os.waitpid(self .pid, 0)
OSError: [Errno 10] No child processes
Is it a requirement that the Popen4 object's wait method be
called from the same thread that created it?
Why does it work on one machine:
Python 2.4.2 (#1, May 7 2006, 17:58:05)
[GCC 3.4.5 (Gentoo 3.4.5-r1, ssp-3.4.5-1.0, pie-8.7.9)] on linux2
Type "help", "copyright" , "credits" or "license" for more information.
But not on another:
Python 2.4.2 (#1, May 7 2006, 17:34:02)
[GCC 3.4.5 (Gentoo 3.4.5-r1, ssp-3.4.5-1.0, pie-8.7.9)] on linux2
Type "help", "copyright" , "credits" or "license" for more information.
--
Grant Edwards
gr****@visi.com