Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'wed,': 0.04; 'python?': 0.07; 'subject:process': 0.07; 'python': 0.07; 'subprocess': 0.09; 'to:name:python list': 0.09; 'am,': 0.14; 'wrote:': 0.14; 'subject:python': 0.15; '*nix': 0.16; '10:45': 0.16; '2.5)': 0.16; 'alternative,': 0.16; 'creation,': 0.16; 'module:': 0.16; 'received:192.168.200': 0.16; 'subprocess,': 0.16; 'termination': 0.16; 'x64': 0.16; 'this?': 0.18; 'header:In-Reply-To:1': 0.22; 'trying': 0.23; 'script': 0.26; 'windows': 0.26; "i'm": 0.26; '(in': 0.27; 'remote': 0.28; 'hi,': 0.29; 'process,': 0.29; 'host': 0.30; 'probably': 0.30; 'whats': 0.31; 'it.': 0.31; 'are:': 0.31; 'url:library': 0.31; 'to:addr:python-list': 0.32; 'url:docs': 0.33; 'handling': 0.33; 'module': 0.33; 'using': 0.34; 'received:192': 0.34; 'header:User-Agent:1': 0.35; 'doing': 0.36; 'feature': 0.36; 'received:192.168': 0.37; 'should': 0.37; 'url:python': 0.37; 'execute': 0.38; 'but': 0.38; 'url:org': 0.38; 'used': 0.38; 'to:addr:python.org': 0.39; 'works': 0.40; 'would': 0.40; 'simple': 0.60; 'best': 0.60; 'choose': 0.61; '2011': 0.62; 'url:net': 0.62; 'easy.': 0.68; 'designed': 0.69; 'descendants': 0.84; 'machines,': 0.84; 'killing': 0.91; 'need,': 0.91 X-IronPort-AV: E=Sophos;i="4.64,313,1301868000"; d="scan'208";a="1540590" X-Virus-Scanned: amavisd-new at zimbra.sequans.com Date: Wed, 04 May 2011 11:47:37 +0200 From: Jean-Michel Pichavant User-Agent: Mozilla-Thunderbird 2.0.0.24 (X11/20100328) MIME-Version: 1.0 To: python list Subject: Re: Running and killing a process in python References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 39 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1304502460 news.xs4all.nl 41103 [::ffff:82.94.164.166]:32901 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:4604 James Mills wrote: > On Wed, May 4, 2011 at 10:45 AM, Astan Chee 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