Running and killing a process in python
Jean-Michel Pichavant
jeanmichel at sequans.com
Wed May 4 05:47:37 EDT 2011
James Mills wrote:
> On Wed, May 4, 2011 at 10:45 AM, Astan Chee <astan.chee at gmail.com> wrote:
>
>> Hi,
>> I'm trying to make a python script (in windows 7 x64 using python 2.5) to
>> start a process, and kill it after x minutes/seconds and kill all the
>> descendants of it.
>> Whats the best way of doing this in python? which module is best suited to
>> do this? subprocess?
>>
>
> Yes start with the subprocess module:
>
> http://docs.python.org/library/subprocess.html
>
> cheers
> James
>
>
As an alternative, you can have a look at
http://codespeak.net/execnet/index.html
This module is designed to execute processes on remote machines, but it
works great on the local host as well.
Among its features are:
"
- easy creation, handling and termination of multiple processes
- fully interoperable between Windows and Unix-ish systems
"
While it has more feature than what you need, if you do simple things,
it stays simple.
(I never used subprocess with Windows, so I don't know if killing
process is that easy. On *nix system, you should probably choose
subprocess, execnet would be overkill)
JM
More information about the Python-list
mailing list