Maximum number of threads

Jeremy Jones zanesdad at bellsouth.net
Wed Sep 29 11:47:31 EDT 2004


Kirby Angell wrote:

> Michael Fuhr wrote:
>
>> What happens when you hit this "hard limit"?  If there's an error
>> message then it might hint at the problem.
>
>
> If I run this program:
>
>
<snip>

>> I'm not current on Linux threading models -- do these versions of
>> Linux create a new process for each thread?  If so, could resource
>> limits be preventing you from creating more threads?
>
>
> I don't think Linux creates a new process for each thread.  Sure seems 
> like this would have to be something related to python since 2.2 could 
> create a thousand or more threads.  Although I have to admit that it 
> is odd that the maximum number of threads I can create on RH9 is 
> different than on FC2.


Versions of RedHat prior to 9 did something that made it appear that 
each thread was a process.  I don't know all the ins and outs (I think 
it had something to do with user-space vs. kernel-space), but when the 
Native Posix Thread Library (NPTL) appeard in RH9, each thread did not 
show up as its own process (say, in top).  I think it's probably an OS 
limitation.  I kicked off the same script on Windows XP that I kicked 
off on FC2 and XP was able to generate over 2000 threads as opposed to 
around 400 for FC2.  I may be wrong, but I think Python relies on the 
underlying OS threading libraries for everything threading related.  
Which is probably why the recent change in either 2.2 or 2.3 for a dummy 
threading module that simulates threading on systems that do not support 
threading.  I know my babbling isn't getting you any closer to a 
solution.....


Jeremy Jones



More information about the Python-list mailing list