[python-win32] how to find / kill child process ?

Tim Roberts timr at probo.com
Tue Sep 8 00:19:49 CEST 2009


Stef Mientki wrote:
> hello,
>
> I start a number of python files with subproces.Popen
> and keep a list of these processes.
> Something like this:
>
>    arguments = [ 'python', self.Source_File ]
>    Proces = subprocess.Popen ( arguments,
>                            cwd   = source_path ,
>                            shell =  ( os.name == 'nt') )
>
>    self.Desktop_Processes.append ( Proces )
>
> Now when I close my program,
> I also want to kill all the processes this program has launched.
>
> The processes that I've started,
> always consists of a command window (invisible),
> and Python as a child process of that command window.

If you don't want the command window at all, just call "pythonw" instead
of "python".  Then, you should be able to kill the Python process directly.

-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the python-win32 mailing list