Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #55857
| From | "John O'Hagan" <research@johnohagan.com> |
|---|---|
| Organization | johnohagan.com |
| Subject | Re: Reassign or discard Popen().stdout from a server process |
| Date | 2011-02-04 15:48 +0000 |
| References | <mailman.1533.1296549030.6505.python-list@python.org> <pan.2011.02.03.09.48.35.672000@nowhere.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1647.1296834558.6505.python-list@python.org> (permalink) |
On Thu, 3 Feb 2011, Nobody wrote: > On Tue, 01 Feb 2011 08:30:19 +0000, John O'Hagan wrote: > > I can't keep reading because that will block - there won't be any more > > output until I send some input, and I don't want it in any case. > > > > To try to fix this I added: > > > > proc.stdout = os.path.devnull > > > > which has the effect of stopping the server from failing, but I'm not > > convinced it's doing what I think it is. > > It isn't. os.path.devnull is a string, not a file. But even if you did: > > proc.stdout = open(os.path.devnull, 'w') > > that still wouldn't work. As mentioned earlier in the thread, I did in fact use open(), this was a typo, [...] > > Is it possible to re-assign the stdout of a subprocess after it has > > started? > > No. > > > Or just close it? What's the right way to read stdout up to a given > > line, then discard the rest? > > If the server can handle the pipe being closed, go with that. Otherwise, > options include redirecting stdout to a file and running "tail -f" on the > file from within Python, or starting a thread or process whose sole > function is to read and discard the server's output. Thanks, that's all clear now. 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. John
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Reassign or discard Popen().stdout from a server process "John O'Hagan" <mail@johnohagan.com> - 2011-02-01 08:30 +0000
Re: Reassign or discard Popen().stdout from a server process "John O'Hagan" <research@johnohagan.com> - 2011-02-04 15:48 +0000
Re: Reassign or discard Popen().stdout from a server process "John O'Hagan" <research@johnohagan.com> - 2011-02-10 08:35 +0000
Re: Reassign or discard Popen().stdout from a server process Nobody <nobody@nowhere.com> - 2011-02-09 05:24 +0000
Re: Reassign or discard Popen().stdout from a server process Nobody <nobody@nowhere.com> - 2011-02-03 09:48 +0000
csiph-web