Message17009
Running the following code under Linux will result in a
crash on the 508th thread started. The error is
OSError: [Errno 24] Too many open files
The nature of the bug seems to be that Python isn't
closing filedescriptors cleanly when running a thread.
---------------------------------------
import os
from threading import Thread
class Crash(Thread):
def run(self):
a = os.popen4('ls')
b = a[1].read()
# uncommenting these lines fixes the problem
# but this isn't really documented as far as
# we can tell...
# a[0].close()
# a[1].close()
for i in range(1000):
t = Crash()
t.start()
while t.isAlive():
pass
print i
---------------------------------------
The same code without threads (Crash as a plain class)
doesn't crash, so the descriptor must be getting taken
care of when the run() method is exited.
import os
class Crash:
def run(self):
a = os.popen4('ls')
b = a[1].read()
for i in range(1000):
t = Crash()
t.run()
print i
|
|
Date |
User |
Action |
Args |
2007-08-23 14:14:48 | admin | link | issue768649 messages |
2007-08-23 14:14:48 | admin | create | |
|