[PEAK] peak events tasks...

Phillip J. Eby pje at telecommunity.com
Wed Jul 7 13:04:30 EDT 2004

At 11:36 AM 7/7/04 -0500, darryl wrote:

>Hey PEAK-sters
>Does anyone have example code or publicly visible projects which use
>peak events etc. especially with respect to twisted support?
>The whole pseudothread (Tasks) thing sounds cool. I just dont' know how to 
>use it :P

The 'peak.tools.supervisor' app uses them a lot.  It's primarily a FastCGI 
application runner, for Unix-ish platforms.  It doesn't do anything with 
Twisted, though.

It spawns at least a couple of Tasks for every subprocess it has running, 
plus several watchdog tasks.  For example, one task keeps track of how many 
subprocesses are running, and if it's less than desired it starts one, then 
waits a preset interval before checking to see if more are needed.  When it 
reaches the number of "desired" processes, it resets the "desired" number 
to the "minimum" number.

Another task monitors how many subprocesses are busy, and if all of them 
are busy, and a HTTP connection is pending, it raises the number of 
"desired" processes, so that the other task can "notice" and start new 

A task for each subprocess monitors a pipe from the child to track whether 
the child process is "busy" or not, and update the count of busy processes 

So, between these various tasks, the system dynamically enforces the rules 
it has been given regarding the maximum frequency of starting subprocesses, 
the minimum number to have running, and so on.

More information about the PEAK mailing list