Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #80279
| Return-Path | <skip.montanaro@gmail.com> |
|---|---|
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.008 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; 'handler': 0.05; 'output': 0.05; 'skip:$ 20': 0.09; 'python': 0.11; 'def': 0.12; 'wrote': 0.14; 'diagnostic': 0.16; 'post-mortem': 0.16; 'sorts': 0.16; 'stderr': 0.16; 'stdout': 0.16; 'subclasses': 0.16; 'do,': 0.16; 'figures': 0.19; 'command': 0.22; 'appears': 0.22; 'shell': 0.22; 'case.': 0.24; 'skip': 0.24; 'server.': 0.24; "i've": 0.25; 'this:': 0.26; 'developing': 0.27; '(this': 0.29; 'respective': 0.29; 'message-id:@mail.gmail.com': 0.30; 'prints': 0.31; 'request,': 0.31; 'file': 0.32; 'run': 0.32; 'running': 0.33; 'actively': 0.33; 'but': 0.35; 'received:google.com': 0.35; 'done': 0.36; 'method': 0.36; 'being': 0.38; 'ends': 0.38; 'window': 0.38; 'to:addr:python-list': 0.38; 'files': 0.38; 'little': 0.38; 'to:addr:python.org': 0.39; 'analysis,': 0.60; 'guarantee': 0.63; 'skip:$ 10': 0.81; 'subject:skip:M 10': 0.84; 'system),': 0.84; 'capture': 0.91 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=ZuCVKcWHsd6vO4MCv+urzSMG9T3STHErKCUcDTyBoL8=; b=dvVqWPBsGNjVIf+ok4nrB5RBLjdNPCx6nn+iUDaF72rFaqt9vN3x5Xuz+M36xAt1Yz W5hV79QjY+QcJ5bo5AaHNAfUgpBg5khTttBrAaA9v8FGDP3tAY6DeBzMjYyZAEd901g1 iUYyFGRbLeIQRmtLl+LmLeAcG8n3a6tCR2D+8I8ahwnvDgXBRNHVQQzXTSoVzYpY16N2 6cwLQY3UAjGxLW2eBLzJeSBTiJLZqaRvPpVa194niCCJEeURDa1nephwDA5Lf+2FZ2d4 4XcqDQ7oGlWWwsBcC7tB2DRYAwo2z1T4pqOPbKHSX7LmyotX8NW2c57gBTENkSDHHM+G 3uTQ== |
| MIME-Version | 1.0 |
| X-Received | by 10.43.129.134 with SMTP id hi6mr5632912icc.62.1415205886706; Wed, 05 Nov 2014 08:44:46 -0800 (PST) |
| Date | Wed, 5 Nov 2014 10:44:46 -0600 |
| Subject | Misunderstanding buffering - flushing isn't |
| From | Skip Montanaro <skip.montanaro@gmail.com> |
| To | Python <python-list@python.org> |
| Content-Type | text/plain; charset=UTF-8 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://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 | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.15506.1415205889.18130.python-list@python.org> (permalink) |
| Lines | 36 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1415205889 news.xs4all.nl 2970 [2001:888:2000:d::a6]:46561 |
| X-Complaints-To | abuse@xs4all.nl |
| Path | csiph.com!usenet.pasdenom.info!bete-des-vosges.org!feed.ac-versailles.fr!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
| Xref | csiph.com comp.lang.python:80279 |
Show key headers only | View raw
I've been developing a little web server. The request handler
subclasses SimpleHTTPRequestHandler. It has a do_GET method which
figures out what work to actually do, then ends with this:
def do_GET(self):
...
sys.stdout.flush()
sys.stderr.flush()
As it's still being actively developed, I've been dumping all sorts of
diagnostic prints to stdout and stderr. I've been running it directly
in a terminal window (this is an openSuSE system), but wanted to
capture stdout and stderr for post-mortem analysis, so I wrote this
little shell script:
#!/bin/bash
PORT=${1:-8008}
BASE=$(dirname $0)
echo port=$PORT pid=$$ > ${PORT}.stdout
while true ; do
python ${BASE}/httpserver.py $PORT >> ${PORT}.stdout 2> ${PORT}.stderr
sleep 1
done
I figured everything would be flushed to the respective .stdout and
.stderr files at the end of every request, but that appears not to be
the case. Do I have to run the python command with the -u flag to
guarantee each request's output is immediately available in the output
file at the end of each request?
Thx,
Skip
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Misunderstanding buffering - flushing isn't Skip Montanaro <skip.montanaro@gmail.com> - 2014-11-05 10:44 -0600
Re: Misunderstanding buffering - flushing isn't Irmen de Jong <irmen.NOSPAM@xs4all.nl> - 2014-11-05 18:29 +0100
Re: Misunderstanding buffering - flushing isn't Skip Montanaro <skip.montanaro@gmail.com> - 2014-11-05 11:54 -0600
Re: Misunderstanding buffering - flushing isn't Chris Angelico <rosuav@gmail.com> - 2014-11-06 05:03 +1100
Re: Misunderstanding buffering - flushing isn't Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-11-06 02:14 +0000
csiph-web