process wrapper?
Steve @ Waypath
steve at waypath.com
Sun Mar 28 20:29:56 EST 2004
I need help. I'm trying to write a process wrapper class in Python (on
Linux) that let's one:
- read service definitions from a config file (where a service definition
includes a bash command to start the service, and the service is a daemon)
- call a method that will start up the service
- call a method that will shut down the service.
- other stuff not relevant here
Where I'm stumped is in starting up the service in a way that:
- doesn't block the running of the main process (i.e. returns control back
to the wrapper, so it will listen for more commands)
- let's me get some kind of handle on the started service that I can later
use to shut down the service.
I've tried every implementation of os.system, os.popen*, os.spawn* , and
(os.fork + os.exec*) for which I can find an example or that I can imagine,
but I can't come up with anything that works for me. os.spawnv() looked
very promising, but every process I start with it goes defunct.
I won't bore you with examples of stuff that doesn't work. I've tried so
many things, my head is spinning. I don't care if I wrap the process in a
handler that my main process controls/kills or if I spin off a process but
track it's PID, to kill later. I don't care if the PID is in memory or
written to a file I can read later.
Can anyone point me in the right direction?
More information about the Python-list
mailing list