Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!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.097 X-Spam-Evidence: '*H*': 0.81; '*S*': 0.00; 'subject:files': 0.09; ':-p': 0.16; 'wrote:': 0.17; 'input': 0.18; 'otherwise,': 0.20; 'object.': 0.22; 'pipe': 0.22; 'sorry,': 0.22; 'example': 0.23; 'this:': 0.23; 'header:In-Reply-To:1': 0.25; 'skip:" 20': 0.26; 'am,': 0.27; 'message-id:@mail.gmail.com': 0.27; '>>>>': 0.29; 'subject:size': 0.29; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'third': 0.34; 'nov': 0.35; 'received:209.85': 0.35; 'should': 0.36; 'received:209': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'subject:-': 0.40; 'header:Received:5': 0.40; 'remove': 0.61; 'first': 0.61; 'more': 0.63; 'gave': 0.65; 'to:name:python': 0.84; 'subject:limited': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=dxYSqVb5PYhBWGDbQqc9lARI8W0yvIVW8nT1B3bSE+s=; b=tEgX2m9W6AJ8aSlPuhr2tqRGynSJEnUIZ4Z5UYonDd8PcFFA3zUE/YY3A0zic05aDm vGxdyMuIJiZCZn1lXPxlqdPmEcUiNtjdBYGpQYeTmLuNymqfkaXaj2s31iiLCBQ2U8KT kJYNkALUPquz+axpbFBwqvEmfj6H2NUuZmMPHLsN7sSmXksjX+xxDkyg1ctG4vLRb9Mr 14KOLUW7NidmLQIZS3KQLFprU3ugjeJZz5cI6jXT1OVG6dOL+ArrUbKK3ketyRz/8WLD JAb+lzKrM+Htqh/Ky91rUan1B8c8fTp+pN1Wu5zK28D+pvJetItrnav+xTLBD1fv6uKp fieA== MIME-Version: 1.0 In-Reply-To: References: <509ab0fa$0$6636$9b4e6d93@newsspool2.arcor-online.net> <509AD812.2060605@gmail.com> From: Ian Kelly Date: Tue, 13 Nov 2012 09:30:55 -0700 Subject: Re: creating size-limited tar files To: Python Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 12 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1352824288 news.xs4all.nl 6969 [2001:888:2000:d::a6]:40755 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:33252 On Tue, Nov 13, 2012 at 9:25 AM, Ian Kelly wrote: > Sorry, the example I gave above is wrong. If you're calling > p1.communicate(), then you need to first remove the p1.stdout pipe > from the Popen object. Otherwise, the communicate() call will try to > read data from it and may "steal" input from p2. It should look more > like this: > >>>> p1 = subprocess.Popen(cmd1, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) >>>> p2 = subprocess.Popen(cmd2, shell=True, stdin=p1.stdout, stdout=subprocess.PIPE, stderr=subprocess.PIPE) >>>> p1.stdout = None Per the docs, that third line should be "p1.stdout.close()". :-P