popen problem
Marco Catunda
catunda at pobox.com
Sun Mar 11 22:51:46 EST 2001
What's wrong with this code?
##########################
import threading
import os
class TestPopen( threading.Thread ):
def run( self ):
while 1:
f = os.popen( "ls -l /" )
lines = f.read()
f.close()
if __name__ == "__main__":
for i in range(50):
t = TestPopen()
t.start()
###########################
Let it run about 1 minute.
And, the result is:
Exception in thread Thread-10:
Traceback (innermost last):
File "/var/tmp/python/python-root/usr/lib/python1.5/threading.py", line
376, in __bootstrap
self.run()
File "teste.py", line 10, in run
f.close()
IOError: (0, 'Error')
Exception in thread Thread-11:
Traceback (innermost last):
File "/var/tmp/python/python-root/usr/lib/python1.5/threading.py", line
376, in __bootstrap
self.run()
File "teste.py", line 10, in run
f.close()
IOError: (0, 'Error')
....
Please, how do I correct it?
I used the same idea in another more complex code and I've had the same
problem.
-- Marco Catunda
More information about the Python-list
mailing list