I am trying to understand what is causing python to raise this error when I create a number of threads:
thread.error: can't start new thread
I have been told that it is due to the default thread size (1 MB), but I have recompiled python defining an alternate threadsize, and I am not seeing any changes. I defined the THREAD_STACK_SIZE in the thread_pthread.h file.
Any ideas?
Here is the code I am using to test the number of threads I can get running. It maxis out at 1031. I have tested it on two systems, one with 1GB of ram and another with 2GB of RAM.
import threading
import time
class Mythread(threading.Thread):
def __init__(self):
self.__live = True
threading.Thread.__init__(self, target=self.runLoop)
def runLoop(self):
while self.__live:
time.sleep(.1)
def stop(self):
self.__live = False
threads = []
max = raw_input("max: ")
if max == 'None':
max = None
else:
max = int(max)
while True:
print len(threads)
t = Mythread()
t.start()
threads.append(t)
if len(threads) == max:
break
print 'all running'
while True:
answer = raw_input("stop now? ")
if answer in ['Y','y']:
break
print "stopping"
for t in threads:
t.stop()
print "joining"
for t in T:
t.join()
while True:
answer = raw_input("Quit now? ")
if answer in ['Y','y']:
break
print "done"
-- http://mail.python.org/mailman/listinfo/python-list