Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #29503
| From | Gene Heskett <gheskett@wdtv.com> |
|---|---|
| Subject | Re: subprocess call is not waiting. |
| Date | 2012-09-19 11:57 -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> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.923.1348070282.27098.python-list@python.org> (permalink) |
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 | Next — Previous in thread | Next in thread | Find similar | Unroll 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