How many threads can I create ???
Bartosz Zembrzuski
Bartosz.Zembrzuski at softax.com.pl
Mon Dec 3 11:58:40 EST 2001
Hi
I've got problem with creating large number of threads on Linux.
My configuration is:
Redhat 7.1 on x86
Kernel 2.4.2-2
Python 2.1
Program is very simple:
import threading
from time import sleep
def fun():
sleep(10)
def main():
threads = []
iter = 100
for i in range(iter):
t = threading.Thread(target = fun)
threads.append(t)
for i in range(iter):
print i
threads[i].start()
for i in range(iter):
threads[i].join()
print 'finished'
main()
86th thread gives me an error:
Traceback (most recent call last):
File "test.py", line 24, in ?
main()
File "test.py", line 17, in main
threads[i].start()
File "/home/guest/Python-2.1/Lib/threading.py", line 360, in start
_start_new_thread(self.__bootstrap, ())
thread.error: can't start new thread
I've no idea what's going on. Under Windows I've created over 2000
python threads until error occures.
Similar program written in C (using pthreads) lets me create over 300
threads (on the same linux machine)
Any suggestions are welcome :)))
Regards
More information about the Python-list
mailing list