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!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:module': 0.04; 'danny': 0.09; 'deprecated': 0.09; 'doc,': 0.09; 'similar?': 0.09; 'output': 0.10; '"on': 0.16; "'-r',": 0.16; "'r')": 0.16; 'docs,': 0.16; 'hangs': 0.16; 'hangs.': 0.16; 'like?': 0.16; 'parallel,': 0.16; 'proc': 0.16; 'received:209.85.213.174': 0.16; 'received :mail-yx0-f174.google.com': 0.16; 'tried:': 0.16; 'cc:addr:python- list': 0.16; 'wrote:': 0.16; 'cheers,': 0.18; '>>>': 0.18; 'subject:skip:s 10': 0.18; 'cc:no real name:2**0': 0.20; 'seems': 0.20; 'trying': 0.21; 'file,': 0.21; 'cc:2**0': 0.22; 'header:In- Reply-To:1': 0.22; 'tue,': 0.23; 'pm,': 0.24; 'aug': 0.24; "i'm": 0.27; 'all,': 0.28; 'message-id:@mail.gmail.com': 0.29; 'cc:addr:python.org': 0.30; 'threads': 0.30; 'chris': 0.32; "what's": 0.33; 'regardless': 0.34; 'external': 0.35; 'skip:" 10': 0.36; 'thread': 0.37; 'communicate': 0.37; 'using': 0.37; 'but': 0.37; 'could': 0.38; 'from:': 0.38; 'portion': 0.38; 'some': 0.38; 'received:google.com': 0.38; 'received:209.85': 0.38; 'skip:o 20': 0.38; 'subject:: ': 0.39; 'your': 0.61; 'back': 0.62; 'database.': 0.74; '11:48': 0.84; '11:56': 0.84; 'isolate': 0.84; 'reverted': 0.84; 'sender:addr:chris': 0.84; 'url:rebertia': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rebertia.com; s=google; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=QBMXW26z7dgQzepqxy3fQeaYK5xHrQHCKUV+hYTeiMg=; b=ZmS7+DJSitdBnFVet1QO3uXEw0GKPyajVkHjKa3daKdN3EUPX6eAJN/8aKgPwyuSsK xiZfETkYsSlo0n+BoFMgT7VHT2PczVnvMIVWzD1kSzbfSKRc+HoFma63ygysxZVzu14R IYup+zbZGtledCZMMu+aJ8Mo7avFwXg2T3zuQ= MIME-Version: 1.0 Sender: chris@rebertia.com In-Reply-To: References: <20110808013500.7c9e30ff44caee0f0bbf988a@johnohagan.com> Date: Wed, 10 Aug 2011 00:36:18 -0700 X-Google-Sender-Auth: gPx-qHZJza0Hv99cUL2YxjrQHWY Subject: Re: subprocess.Popen and thread module From: Chris Rebert To: "Danny Wong (dannwong)" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: python-list@python.org 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: 45 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1312961781 news.xs4all.nl 23903 [2001:888:2000:d::a6]:44176 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:11101 > From: Chris Rebert >> On Tue, Aug 9, 2011 at 11:38 PM, Danny Wong (dannwong) >> wrote: >>> Hi All, >>> =C2=A0 I'm trying to execute some external commands from multiple datab= ase. >>> I'm using threads and subprocess.Popen ( from docs, all the popen* >>> functions are deprecated and I was told to use subprocess.Popen) to >>> execute the external commands in parallel, but the commands seems to >>> hang. >> >> What's your Popen() call look like? > > On Tue, Aug 9, 2011 at 11:48 PM, Danny Wong (dannwong) > wrote: >> =C2=A0 =C2=A0try: >> =C2=A0 =C2=A0 =C2=A0 =C2=A0cmd_output =3D subprocess.Popen(['scm', 'load= ', '--force', '-r', nickname, '-d', directory, project], stdout=3Dsubproces= s.PIPE, stderr=3Dsubprocess.PIPE) >> =C2=A0 =C2=A0 =C2=A0 =C2=A0status =3D cmd_output.wait() > > Er, did you read the warning about Popen.wait() in the docs? (emphasis ad= ded): On Tue, Aug 9, 2011 at 11:56 PM, Danny Wong (dannwong) wrote: > I did read that portion of the doc, then I change it to communicate and i= t still hangs. So I reverted back to "wait" while launching one thread to s= ee if I could isolate the problem, but it still hangs regardless of using "= wait" or "communicate". Since you want to log the output to a file, have you tried: logfile =3D open("path/to/file", 'r') proc =3D subprocess.Popen(['scm', 'load', '--force', '-r', nickname, '-d', directory, project], stdout=3Dlogfile, stderr=3Dsubprocess.STDOUT) status =3D proc.wait() or similar? Cheers, Chris -- Damn Outlook/Exchange and its "On Behalf Of"! http://rebertia.com