Communication between a Python process and a Python cgi scrip t

Gustavo Cordova gcordova at hebmex.com
Thu Apr 11 15:44:22 EDT 2002


> I have a Python program started by root that does some magic stuff
> every 10 minutes. So the program in an infinite loop of 
> sleep, do stuff,
> sleep, do stuff... How can I make a cgi-script to end the process's
> sleep phase and make it to "do stuff" immediately. I tried 
> signals, but
> it is propably too risky because the process is run as root. Any
> suggestions?

¿How can it be risky?

If it's risky, and you're trying to activate it with a CGI,
then maybe you shouldn't use a CGI to activate it.

On the other hand, the process could wait for a SIGALRM (alarm).
SO, now, your program can:

1. Setup alarm to signal after X seconds.
2. Sleep forever.
3. Catch alarm, do stuff.
4. Goto 1.

Now, your CGI simply sends a SIGALRM to the process,
which starts the cycle again.

Kinda neato.

-gustavo





More information about the Python-list mailing list