On Wed, Apr 21, 2010 at 8:57 AM, Paweł Stradomski <[email protected]> wrote:
> 2010/4/21 jazg <[email protected]>:
>>
>> Why would it prevent future requests if each request is a new thread?
>>
>> I could manually create another thread for the job, but it seems like that
>> should not be necessary. I still don't understand why setting content-length
>> didn't work, did pylons decide to override that for some reason?
>
> CherryPy definitely (and AFAIK paster too) uses a pool of worker
> threads. Starting a new thread for each request would be inefficient
> (both by having too many concurrent threads and by starting a new
> thread for each request, which is costly).
> This is similar to how Apache/mpm_prefork keeps a pool of processes.
>
> So, with a pool of eg 10 threads (default for CherryPy) ten requests
> that start those long-running tasks would deplete the pool completely.
> Further requests would be queued until one of the workers finishes.

PasteHTTPServer has a flexible number of threads, as many other
servers do. See paste/httpserver.py, ThreadPool and
WSGIThreadPoolServer docstrings and constructor args. The default is
10 threads ("workers").

    "When there are no idle workers and a request comes in, another
    worker *may* be spawned.  If there are less than spawn_if_under
    threads in the busy state, another thread will be spawned.  So if
    the limit is 5, and there are 4 hung threads and 6 busy threads,
    no thread will be spawned."

    "hung threads are threads that have been busy more than
    hung_thread_limit seconds.  Hung threads are killed when they live
    longer than kill_thread_limit seconds.  A thread is then
    considered dying for dying_limit seconds, if it is still alive
    after that it is considered a zombie."

You can set at least some of these variables directly in the [server]
section of the INI file.

There's also a ThreadPool.track_threads() method you can call to get a
summary of the server's state, although I don't know how you'd access
that method from a Pylons app.

-- 
Mike Orr <[email protected]>

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en.

Reply via email to