Maximum number of threads

Jeremy Jones zanesdad at bellsouth.net
Wed Sep 29 07:46:33 EDT 2004


Kirby Angell wrote:

> We are porting our applications from Python 2.2 on RH9 to Python 2.3 
> on RH9.  One of our apps used to be able to create threads with wild 
> abandon, 800 or more if necessary.  With Python 2.3 we are hitting a 
> hard limit of 254 on RH9 and around 400 on FC2.
>
> What is the limiting factor for the number of threads we can create?  
> Is there a way to increase it?
>
> -- Kirby

Interesting.  I modified a little threading script that I have and it 
puked around creating the 404-405th thread (I'm also running on FC2):

Starting thread 404
initing thread 404
Traceback (most recent call last):
  File "spawn_threads.py", line 28, in ?
    dn.start()
  File "/usr/lib/python2.3/threading.py", line 410, in start
    _start_new_thread(self.__bootstrap, ())
thread.error: can't start new thread

The only threading changes that I found on the "What's New in Python 
2.3" page was this:

"""
The thread and threading modules now have companion modules, 
dummy_thread and dummy_threading, that provide a do-nothing 
implementation of the thread module's interface for platforms where 
threads are not supported. The intention is to simplify thread-aware 
modules (ones that /don't/ rely on threads to run) by putting the 
following code at the top:

try:
    import threading as _threading
except ImportError:
    import dummy_threading as _threading

In this example, _threading is used as the module name to make it clear 
that the module being used is not necessarily the actual threading 
module. Code can call functions and use classes in _threading whether or 
not threads are supported, avoiding an if statement and making the code 
slightly clearer. This module will not magically make multithreaded code 
run without threads; code that waits for another thread to return or to 
do something will simply hang forever.


"""
...so I'm not sure what changed to cause you grief.  Just out of 
curiosity, what are you doing that makes you feel like you need to 
"create threads with wild abandon"?  Typically, I think of it as a 
little scary to just let your program spawn as many threads as it can.

Jeremy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20040929/dd844d27/attachment.html>


More information about the Python-list mailing list