Python with many threads

Michel Talon talon at lpthe.jussieu.fr
Tue Dec 16 14:29:46 UTC 2008


Otto wrote:

> Exception in thread 30:
> Traceback (most recent call last):
>   File "/usr/local/lib/python2.5/threading.py", line 486, in
> __bootstrap_in=
> ner
>     self.run()
> 
> The number of errors increases rapidly with even bigger number of
> threads.
> Is there any way I can increase the maximum number of Python threads?


Nothing limits the number of concurrent threads. Personnally i have
checked i can run Grub Next Generation Python Client with 600 threads
without any problem.
niobe% uname -a
FreeBSD niobe.lpthe.jussieu.fr 7.0-STABLE FreeBSD 7.0-STABLE #0: Tue Jul
22 10:31:01 CEST 2008
niobe% python
Python 2.5.2 (r252:60911, Jul  5 2008, 13:44:44) 

Recall that python threads are just native threads, but these threads
are protected from trashing the python state by a single lock, the GIL,
which is released when you do IO. This allows to effectively thread IO,
but not python computation. The FreeBSD thread library has no particular
limitations, you can run hundreds or thousands of threads without much
problem, for example under Java.


-- 

Michel TALON



More information about the freebsd-questions mailing list