Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!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.013 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'suppose': 0.07; 'sys': 0.07; 'cc:addr:python-list': 0.11; '(there': 0.16; 'cc:name:python list': 0.16; 'localhost': 0.16; 'popping': 0.16; 'tcp': 0.16; 'test).': 0.16; 'tty': 0.16; '(the': 0.22; 'import': 0.22; 'cc:addr:python.org': 0.22; 'versions': 0.24; 'cc:2**0': 0.24; 'second': 0.26; 'least': 0.26; 'header:In-Reply-To:1': 0.27; 'character': 0.29; 'message-id:@mail.gmail.com': 0.30; 'file': 0.32; "we're": 0.32; 'run': 0.32; 'another': 0.32; 'skip:# 10': 0.33; 'received:google.com': 0.35; 'done': 0.36; 'two': 0.37; 'that,': 0.38; 'even': 0.60; 'read': 0.60; 'different': 0.65; 'acts': 0.74; '9000': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=iOXxEyTMoQtJ4/yofJcmWanPhMpFAQssNjhilNJPlyg=; b=u+A0Sakk6jPHVZkFIpqKCdnv2NRgzxNUfAS6Zee1YANvDgoV1HgTJzGCN5HDNjXMxx iD/s4+y39TD3i2/6G/MhuIiIzwj/63LdOwq0a5u9wzdQQFgma1T42W4Kp5CeJq+FZebY J/LnuQaChFHJm29R9PoaKn/W2/vuhxu6Nwj/Z+NxqfXLgDg6j7ewyYOZzcmGgAS7Wngs D5Ydpxmxf6xXZJGjDrDQC0g5tIIZ0b7TA4XkN6/5XhQ8qN1T3cAVUG0zkUnlr13eaJZ6 /aoAa+xP3aiNo99yRjSD14AznqKag8v1d0udfN2REtyr8JryYJmlReaofD5iyncEBWwq B9Qw== MIME-Version: 1.0 X-Received: by 10.112.198.73 with SMTP id ja9mr30074175lbc.19.1413845571297; Mon, 20 Oct 2014 15:52:51 -0700 (PDT) In-Reply-To: References: <87a94rgxi5.fsf@elektro.pacujo.net> Date: Mon, 20 Oct 2014 15:52:51 -0700 Subject: Re: Flush stdin From: Dan Stromberg To: Marko Rauhamaa Content-Type: text/plain; charset=UTF-8 Cc: Python List 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: 25 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1413845578 news.xs4all.nl 2936 [2001:888:2000:d::a6]:37918 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:79348 If I run the following in one tty: nc -l localhost 9000 | /tmp/z ...where /tmp/z has just: #!/usr/bin/python3 import sys for line in sys.stdin.buffer: print(line) And then run the following in another tty on the same computer: while read line; do echo $line; sleep 1; done < /etc/passwd | nc localhost 9000 ...then everything acts line buffered, or perhaps even character buffered (the two are pretty indistinguishable in this test). What I see is my /etc/passwd file popping out of the nc -l side, one line at a time, each line one second apart. I suppose this suggests that it's the client that's sending TCP data that is buffering. That, or we're using two different versions of netcat (there are at least two available).