How to increase number of threads per process?

Ronan Viernes Ronan.Viernes at onsemi.com
Tue Jul 13 08:29:05 CEST 2004


Hi,

I have created a python script (see below) to count the maximum number
of threads per process (by starting new threads continuously until it
breaks).

######
#testThread.py
import thread, sys

def main():
    print "Main Thread:", thread.get_ident()
    count = 0;
    try:
        while 1:
            thread.start_new_thread(test,(`count`,))
            count = count + 1;
    except:
        print "Total Threads:", count
        print "Exiting Main Thread:", thread.get_ident()
        raise

def test(input=None):
    print "count:", thread.get_ident(), input
    while 1: #keep thread alive until it breaks
        pass

if __name__ == "__main__":
    main()

#####

Results:

1. SuSE Professional 7.1 (Kernel 2.4.18), Python 1.5.2
   Max Threads = 1024

2. SuSE Professional 7.1 (Kernel 2.4.18), Python 2.0
   Max Threads = 1024

3. SuSE Enterprise Server 8.0 (Kernel 2.4.18), Python 1.5.2
   Max Threads = 256

4. SuSE Enterprise Server 8.0 (Kernel 2.4.18), Python 2.2
   Max Threads = 512

Note:
   For all setup, SuSE Linux threads-max=14336 and max_map_count=65536

Questions:
1. How to determine the number of threads? Is it something
configurable?
2. Why do the results above differ in output?
3. How to increase the maximum number of threads per process?


Thanks and hope to hear soon.
Ronan



More information about the Python-list mailing list