Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #29503

Re: subprocess call is not waiting.

Path csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <gheskett@wdtv.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.017
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'reject': 0.05; 'exit': 0.07; 'finished,': 0.07; 'problem?': 0.07; 'run,': 0.07; 'python': 0.09; 'blocked': 0.09; 'observation': 0.09; 'threads.': 0.09; 'anyway': 0.11; 'subject:not': 0.11; 'thread': 0.11; 'end-of- file': 0.16; 'proc': 0.16; 'processes.': 0.16; 'soap,': 0.16; 'wrote:': 0.17; 'differ': 0.17; 'shell': 0.18; 'cheers,': 0.23; 'this:': 0.23; 'command': 0.24; 'tried': 0.25; 'header:In-Reply- To:1': 0.25; 'leave': 0.26; 'instead.': 0.27; 'options': 0.27; 'correct': 0.28; 'run': 0.28; '"the': 0.29; 'probably': 0.29; 'url :non-standard http port': 0.30; 'problem.': 0.32; 'running': 0.32; 'defense': 0.33; 'scroll': 0.33; 'up!': 0.33; 'wednesday': 0.33; 'to:addr:python-list': 0.33; 'massive': 0.35; 'really': 0.36; 'should': 0.36; 'possible': 0.37; 'why': 0.37; 'quite': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'nothing': 0.38; 'shows': 0.38; 'page': 0.38; 'to:addr:python.org': 0.39; 'takes': 0.39; 'header:Received:5': 0.40; 'your': 0.60; 'most': 0.61; 'charset:windows-1256': 0.61; "you'll": 0.62; 'header:Message- Id:1': 0.62; 'between': 0.63; 'show': 0.63; 'sounds': 0.71; 'received:204': 0.72; '100%': 0.76; '(they': 0.84; 'andrea': 0.84; 'everything.': 0.84; 'reap': 0.84; 'received:66.118': 0.84; 'running,': 0.84; 'dennis': 0.91; 'processes,': 0.93
X-Spam-Status No, score=-2.1 required=5.0
X-Spam-Level
From Gene Heskett <gheskett@wdtv.com>
To python-list@python.org
Subject Re: subprocess call is not waiting.
Date Wed, 19 Sep 2012 11:57:47 -0400
References <d49e1e71-afe2-4aab-8c67-3e2eea6533a6@googlegroups.com> <mailman.906.1348050393.27098.python-list@python.org> <5059c765$0$6952$e4fe514c@news2.news.xs4all.nl>
In-Reply-To <5059c765$0$6952$e4fe514c@news2.news.xs4all.nl>
MIME-Version 1.0
Content-Type Text/Plain; charset="windows-1256"
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.923.1348070282.27098.python-list@python.org> (permalink)
Lines 62
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1348070282 news.xs4all.nl 6949 [2001:888:2000:d::a6]:40354
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:29503

Show key headers only | View raw


On Wednesday 19 September 2012 11:56:44 Hans Mulder did opine:

> On 19/09/12 12:26:30, andrea crotti wrote:
> > 2012/9/18 Dennis Lee Bieber <wlfraed@ix.netcom.com>:
> >>         Unless you have a really massive result set from that "ls",
> >>         that
> >> 
> >> command probably ran so fast that it is blocked waiting for someone
> >> to read the PIPE.
> > 
> > I tried also with "ls -lR /" and that definitively takes a while to
> > run, when I do this:
> > 
> > proc = subprocess.Popen(['ls', '-lR', '/'], stdout=subprocess.PIPE,
> > stderr=subprocess.PIPE)
> > 
> > nothing is running, only when I actually do
> > proc.communicate()
> > 
> > I see the process running in top..
> > Is it still an observation problem?
> 
> Yes: using "top" is an observation problem.
> 
> "Top", as the name suggests, shows only the most active processes.
> 
Which is why I run htop in a shell 100% of the time.  With htop, you can 
scroll down and see everything.

> It's quite possible that your 'ls' process is not active, because
> it's waiting for your Python process to read some data from the pipe.
> 
> Try using "ps" instead.  Look in thte man page for the correct
> options (they differ between platforms).  The default options do
> not show all processes, so they may not show the process you're
> looking for.
> 
> > Anyway I also need to know when the process is over while waiting, so
> > probably a thread is the only way..
> 
> This sounds confused.
> 
> You don't need threads.  When 'ls' finishes, you'll read end-of-file
> on the proc.stdout pipe.  You should then call proc.wait() to reap
> its exit status (if you don't, you'll leave a zombie process).
> Since the process has already finished, the proc.wait() call will
> not actually do any waiting.
> 
> 
> Hope this helps,
> 
> -- HansM


Cheers, Gene
-- 
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
My web page: <http://coyoteden.dyndns-free.com:85/gene> is up!
To know Edina is to reject it.
		-- Dudley Riggs, "The Year the Grinch Stole the Election"

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

subprocess call is not waiting. paulstaten@gmail.com - 2012-09-13 08:17 -0700
  Re: subprocess call is not waiting. MRAB <python@mrabarnett.plus.com> - 2012-09-13 16:35 +0100
  Re: subprocess call is not waiting. woooee@gmail.com - 2012-09-13 10:24 -0700
    Re: subprocess call is not waiting. Hans Mulder <hansmu@xs4all.nl> - 2012-09-14 10:52 +0200
  Re: subprocess call is not waiting. Chris Rebert <clp2@rebertia.com> - 2012-09-13 22:27 -0700
  Re: subprocess call is not waiting. paulstaten@gmail.com - 2012-09-14 05:22 -0700
    Re: subprocess call is not waiting. Wanderer <wanderer@dialup4less.com> - 2012-09-14 10:38 -0700
    Re: subprocess call is not waiting. Chris Rebert <clp2@rebertia.com> - 2012-09-14 21:02 -0700
      Re: subprocess call is not waiting. paulstaten@gmail.com - 2012-09-15 05:59 -0700
        Re: subprocess call is not waiting. andrea crotti <andrea.crotti.0@gmail.com> - 2012-09-18 14:54 +0100
        Re: subprocess call is not waiting. Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-09-18 15:20 -0400
        Re: subprocess call is not waiting. andrea crotti <andrea.crotti.0@gmail.com> - 2012-09-19 11:26 +0100
          Re: subprocess call is not waiting. Hans Mulder <hansmu@xs4all.nl> - 2012-09-19 15:23 +0200
            Re: subprocess call is not waiting. Gene Heskett <gheskett@wdtv.com> - 2012-09-19 11:57 -0400
            Re: subprocess call is not waiting. andrea crotti <andrea.crotti.0@gmail.com> - 2012-09-19 17:34 +0100
              Re: subprocess call is not waiting. Hans Mulder <hansmu@xs4all.nl> - 2012-09-19 19:31 +0200

csiph-web