This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mdoudoroff
Recipients
Date 2003-07-09.18:36:58
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
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
History
Date User Action Args
2007-08-23 14:14:48adminlinkissue768649 messages
2007-08-23 14:14:48admincreate