Communication between a Python process and a Python cgi script

Todd Warner taw at redhat.com
Thu Apr 11 19:38:02 EDT 2002


On Thu, 11 Apr 2002, Joonas Paalasmaa wrote:
> 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?

One way:
Use a cron job to execute it every ten minutes would be very simple.
But it can't be nicely ended via a CGI script that I can think of off
the top of my head. And it won't perform an action immediately.

Another:
Alternatively, and probably ideally. Make it a service. Start playing
with os.fork() to toss it to the background, and have it listen through
a socket for an exit or action string. Make a cgi script that sends that
enabling string through the socket. Look in /etc/init.d/ for examples of
how to make something a service.

Another option:
cgi script sends a kill and SIGALRM. *shrug* Depends on what the risk is.

-- 
____________
 /odd "traceback" Warner                        <taw@{redhat,pobox}.com>
Tank Commander - NC Army National Guard   Bit Twiddler - Red Hat Network
---------------------gpg info in the message headers--------------------
"Eat dessert now; life is uncertain" -- unknown









More information about the Python-list mailing list