Thread limitations and SocketServer?

Gordon McMillan gmcm at hypernet.com
Tue Mar 21 16:25:58 EST 2000


sblakey wrote:

> I am running a SocketServer on a Linux box (/prov/version is 
> Linux version 2.2.13 (root at ooc3) (gcc version egcs-2.91.66 19990314/Linux 
> (egcs-1.1.2 release)) #2 SMP Wed Dec 29 07:57:42 PST 1999) and am
> running into a thread-related problem.
> 
> Once this server is hit with a heavy enough load, the following
> traceback begins to appear with alarming frequencey:
> 
> Traceback (innermost last):
>   File "/usr/lib/python1.5/SocketServer.py", line 213, in handle_request
>     self.process_request(request, client_address)
>   File "/usr/lib/python1.5/SocketServer.py", line 321, in process_request
>     (request, client_address))
> error: can't start new thread


> Obviously some internal limitation on the number of concurrent threads
> is being reached.  My question is: is this problwm solvable within
> python?  

Nope.

> Is this a limitation of the python thread implementatio, or
> will I need to dive down deeper to the underlying pthreads?  

The latter.

> Will I
> have the same problem if I rework the server to use asyncore instead of
> SocketServer?

If you rework the server to use asyncore, you'll end up with 
Medusa. That will do great for high volume as long as there's 
no CGI. For CGI, the big boys all use either a thread pool or 
sub-process pool. 

- Gordon




More information about the Python-list mailing list