Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #29048
| Path | csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python@mrabarnett.plus.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'python': 0.09; 'exist.': 0.09; 'files"': 0.09; 'happens.': 0.09; 'stderr': 0.09; 'stdout': 0.09; 'subset': 0.09; 'wrong,': 0.09; 'subject:not': 0.11; 'times,': 0.13; 'copies),': 0.16; 'datasets': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'intended.': 0.16; 'loops': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'proc': 0.16; 'received:84.93': 0.16; 'received:84.93.230': 0.16; 'wait.': 0.16; 'wrote:': 0.17; 'successful,': 0.17; 'tries': 0.17; 'shell': 0.18; 'tests': 0.18; 'trying': 0.21; 'error.': 0.21; 'not,': 0.21; 'supposed': 0.21; 'tells': 0.22; 'runs': 0.22; "i've": 0.23; 'command': 0.24; 'script': 0.24; 'tried': 0.25; 'header:In-Reply- To:1': 0.25; 'header:User-Agent:1': 0.26; "doesn't": 0.28; 'run': 0.28; 'post': 0.28; 'fast.': 0.29; 'loop,': 0.29; 'received:192.168.1.3': 0.29; 'url:mailman': 0.29; 'related': 0.30; 'connection': 0.30; 'returned': 0.30; 'code': 0.31; 'url:python': 0.32; 'file': 0.32; '-----': 0.32; 'etc.)': 0.32; 'quickly': 0.32; 'received:84': 0.32; 'print': 0.32; 'url:listinfo': 0.32; 'says': 0.33; 'skip:s 30': 0.33; 'like:': 0.33; 'turns': 0.33; 'to:addr:python-list': 0.33; 'times.': 0.33; 'server': 0.35; 'data,': 0.35; 'returning': 0.35; 'open': 0.35; 'remote': 0.35; 'something': 0.35; 'but': 0.36; 'url:org': 0.36; 'should': 0.36; 'possible': 0.37; 'why': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'nothing': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'received:192.168': 0.40; 'url:mail': 0.40; 'back': 0.62; 'ever': 0.63; 'times': 0.63; 'useful.': 0.65; 'header:Reply-To:1': 0.68; 'internet': 0.71; 'reply-to:no real name:2**0': 0.72; 'prompt': 0.78; '"too': 0.84; 'around,': 0.84; 'communicate,': 0.84; 'reply-to:addr:python.org': 0.84 |
| X-CM-Score | 0.00 |
| X-CNFS-Analysis | v=2.0 cv=IekFqBWa c=1 sm=1 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=AAvI7MrX_rgA:10 a=3F8dre34338A:10 a=ihvODaAuJD4A:10 a=OUOv7kDek9cA:10 a=8nJEP1OIZ-IA:10 a=EBOSESyhAAAA:8 a=8AHkEIZyAAAA:8 a=wfN0js7fSWEA:10 a=aor7pJ5no83jZOaDEJMA:9 a=wPNLvfGTeEIA:10 a=0nF1XD0wxitMEM03M9B4ZQ==:117 |
| X-AUTH | mrabarnett:2500 |
| Date | Thu, 13 Sep 2012 16:46:38 +0100 |
| From | MRAB <python@mrabarnett.plus.com> |
| User-Agent | Mozilla/5.0 (Windows NT 5.1; rv:15.0) Gecko/20120907 Thunderbird/15.0.1 |
| MIME-Version | 1.0 |
| To | python-list@python.org |
| Subject | Re: subprocess call is not waiting. |
| References | <746448155.528147.1347550469072.JavaMail.root@sequans.com> |
| In-Reply-To | <746448155.528147.1347550469072.JavaMail.root@sequans.com> |
| 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.15 |
| Precedence | list |
| Reply-To | python-list@python.org |
| 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.616.1347551196.27098.python-list@python.org> (permalink) |
| Lines | 47 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1347551196 news.xs4all.nl 6962 [2001:888:2000:d::a6]:41986 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:29048 |
Show key headers only | View raw
On 2012-09-13 16:34, Jean-Michel Pichavant wrote: > ----- Original Message ----- >> I have a subprocess.call which tries to download a data from a remote >> server using HTAR. I put the call in a while loop, which tests to >> see if the download was successful, and if not, loops back around up >> to five times, just in case my internet connection has a hiccup. >> >> Subprocess.call is supposed to wait. >> >> But it doesn't work as intended. The loop quickly runs 5 times, >> starting a new htar command each time. After five times around, my >> program tells me my download failed, because the target file doesn't >> yet exist. But it turns out that the download is still >> happening---five times. >> >> When I run htar from the shell, I don't get a shell prompt again >> until after the download is complete. How come control is returned >> to python before the htar command is through? >> >> I've tried using Popen with wait and/or communicate, but no waiting >> ever happens. This is troublesome not only because I don't get to >> post process my data, but because when I run this script for >> multiple datasets (checking to see whether I have local copies), I >> quickly get a "Too many open files" error. (I began working on that >> by trying to use Popopen with fds_close, etc.) >> >> Should I just go back to os.system? >> -- >> http://mail.python.org/mailman/listinfo/python-list >> > > A related subset of code would be useful. > > You can use subprocess.PIPE to redirect stdout & stderr et get them with communicate, something like: > > proc = subprocess.Popen(['whatever'], stdout=subprocess.PIPE, stdout=subprocess.PIPE) > stdout, stderr = proc.communicate() > print stdout > print stderr > > Just by looking at stdout and stderr, you should be able to see why htar is returning so fast. > > JM > > PS : if you see nothing wrong, is it possible that htar runs asynchronously ? > The OP says that it waits when run from the shell.
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Re: subprocess call is not waiting. MRAB <python@mrabarnett.plus.com> - 2012-09-13 16:46 +0100
Re: subprocess call is not waiting. paulstaten@gmail.com - 2012-09-13 11:36 -0700
Re: subprocess call is not waiting. Chris Rebert <clp2@rebertia.com> - 2012-09-13 22:24 -0700
Re: subprocess call is not waiting. paulstaten@gmail.com - 2012-09-13 11:36 -0700
csiph-web