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


Groups > comp.lang.python > #55705

Re: Reassign or discard Popen().stdout from a server process

Path csiph.com!eeepc.pasdenom.info!news.pasdenom.info!news.dougwise.org!news.davenulle.org!gegeweb.org!aioe.org!feeder.news-service.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <johnmohagan@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'attempting': 0.04; 'received:localnet': 0.05; 'differently.': 0.07; 'mode,': 0.07; 'none)': 0.07; 'produces': 0.07; 'run,': 0.07; 'subject:process': 0.07; 'garbage': 0.09; 'i/o': 0.09; 'non-blocking': 0.09; 'server,': 0.12; 'wrote:': 0.14; "doesn't.": 0.16; 'ignores': 0.16; 'pipe,': 0.16; 'stdout': 0.16; 'subject:discard': 0.16; 'subject:server': 0.16; 'feb': 0.16; 'seems': 0.17; 'cases': 0.21; 'nobody': 0.21; 'producing': 0.21; 'tried': 0.22; 'object': 0.22; 'sender:addr:gmail.com': 0.22; 'buffer': 0.23; 'changes.': 0.23; 'fails': 0.23; 'once.': 0.23; 'realise': 0.23; 'header:In-Reply- To:1': 0.23; 'blocking': 0.24; 'right,': 0.24; "didn't": 0.25; 'asked': 0.25; "wouldn't": 0.25; 'closing': 0.27; 'fail': 0.28; 'files,': 0.28; 'messages.': 0.28; 'process,': 0.28; "i'm": 0.28; 'curious': 0.28; '(so': 0.30; 'stops': 0.30; 'strings,': 0.30; 'program,': 0.30; 'server': 0.30; 'list': 0.31; 'to:addr:python- list': 0.31; 'starting': 0.31; '(the': 0.31; 'fri,': 0.31; 'thu,': 0.31; "doesn't": 0.32; 'thanks.': 0.32; 'up.': 0.33; 'file': 0.34; 'surprised': 0.34; 'header:User-Agent:1': 0.34; 'error.': 0.35; 'explain': 0.35; 'another': 0.35; 'using': 0.35; 'but': 0.36; 'open': 0.36; 'consistent': 0.36; 'sounds': 0.36; 'rather': 0.36; 'close': 0.37; 'received:209.85': 0.38; 'either': 0.38; 'received:google.com': 0.38; 'end': 0.38; 'that,': 0.39; 'subject:: ': 0.39; 'to:addr:python.org': 0.40; 'still': 0.40; "it's": 0.40; 'header:Message-Id:1': 0.61; 'due': 0.69; 'become': 0.70; 'soon': 0.75; "(i've": 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:sender:from:organization:to:subject:date :user-agent:references:in-reply-to:mime-version:content-type :content-transfer-encoding:message-id; bh=ON8NFM3uelHr3CdmGWSAnHtvm0QYFPxuxGBYzWrf0RM=; b=ps/YGYlNbjQwKiypl6v3IvcZI44oOPo8m0hglAGsKKe8SOrifeXhmZhUWkrQ9haZwa bOba4J2CH/FlHn8c3guXrLBede7VOMl+juChTbsv/2TUI4w2AErotWzXPRXnM3G3pFbQ PHJNBBymv71TMPnwkbxyZPdRsnH/NYRRrw2v4=
DomainKey-Signature a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:from:organization:to:subject:date:user-agent:references :in-reply-to:mime-version:content-type:content-transfer-encoding :message-id; b=QLBF0AyB+fM0uNMBfbW8dMoGigwZejCAFQAdrjwhBHa8buq6kiRhN7yIIGmBRzwCWh nAZ26oz+ciHOB7R+Cfn7Qr9Ofw5fiaAz6poI28gWQ8fEahk3UPNqYMNwJwCBKpcZz60b gW1MlrMfG4kmSorb06+9fAvVtIIHOQ0k6KxR0=
Sender "John O'Hagan" <johnmohagan@gmail.com>
From "John O'Hagan" <research@johnohagan.com>
Organization johnohagan.com
To python-list@python.org
Subject Re: Reassign or discard Popen().stdout from a server process
Date Sat, 12 Feb 2011 05:32:01 +0000
User-Agent KMail/1.13.5 (Linux/2.6.32-2011-01-16-16.13; KDE/4.4.5; i686; ; )
References <mailman.1533.1296549030.6505.python-list@python.org> <mailman.72.1297326936.1633.python-list@python.org> <pan.2011.02.11.18.37.08.719000@nowhere.com>
In-Reply-To <pan.2011.02.11.18.37.08.719000@nowhere.com>
MIME-Version 1.0
Content-Type Text/Plain; charset="iso-8859-1"
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
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.129.1297488734.1633.python-list@python.org> (permalink)
Lines 40
NNTP-Posting-Host 82.94.164.166
X-Trace 1297488734 news.xs4all.nl 81482 [::ffff:82.94.164.166]:58682
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:55705

Show key headers only | View raw


On Fri, 11 Feb 2011, Nobody wrote:
> On Thu, 10 Feb 2011 08:35:24 +0000, John O'Hagan wrote:
> >> > But I'm still a little curious as to why even unsuccessfully
> >> > attempting to reassign stdout seems to stop the pipe buffer from
> >> > filling up.
> >> 
> >> It doesn't. If the server continues to run, then it's ignoring/handling
> >> both SIGPIPE and the EPIPE error. Either that, or another process has
> >> the read end of the pipe open (so no SIGPIPE/EPIPE), and the server is
> >> using non-blocking I/O or select() so that it doesn't block writing its
> >> diagnostic messages.
> > 
> > The server fails with stdout=PIPE if I don't keep reading it, but
> > doesn't fail if I do stdout=anything (I've tried files, strings,
> > integers, and None) soon after starting the process, without any other
> > changes. How is that consistent with either of the above conditions? I'm
> > sure you're right, I just don't understand.
> 
> What do you mean by "fail". I wouldn't be surprised if it hung, due to the
> write() on stdout blocking. If you reassign the .stdout member, the
> existing file object is likely to become unreferenced, get garbage
> collected, and close the pipe, which would prevent the server from
> blocking (the write() will fail rather than blocking).
> 
> If the server puts the pipe into non-blocking mode, write() will fail with
> EAGAIN if you don't read it but with EPIPE if you close the pipe. The
> server may handle these cases differently.

By "fail" I mean the server, which is the Fluidsynth soundfont rendering 
program, stops producing sound in a way consistent with the blocked write() as 
you describe. It continues to read stdin; in fact, Ctrl+C-ing out of the block 
produces all the queued sounds at once. 

What I didn't realise was that the (ineffective) reassignment of stdout has the 
side-effect of closing it by dereferencing it, as you explain above. I asked on 
the Fluidsynth list and currently it ignores if the pipe it's writing to has 
been closed . All makes sense now, thanks.


John

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


Thread

Re: Reassign or discard Popen().stdout from a server process Nobody <nobody@nowhere.com> - 2011-02-11 18:37 +0000
  Re: Reassign or discard Popen().stdout from a server process "John O'Hagan" <research@johnohagan.com> - 2011-02-12 05:32 +0000

csiph-web