Path: csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-1.proxad.net!hq-usenetpeers.eweka.nl!hq-usenetpeers.eweka.nl!bcyclone01.am1.xlned.com!bcyclone01.am1.xlned.com!newsfeed.xs4all.nl!newsfeed1.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.019 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'python': 0.11; '12:38,': 0.16; '>the': 0.16; '>to': 0.16; 'chris,': 0.16; 'flush': 0.16; 'from:addr:cs': 0.16; 'from:addr:zip.com.au': 0.16; 'from:name:cameron simpson': 0.16; 'message-id:@cskk.homeip.net': 0.16; 'quantum': 0.16; 'received:211.29': 0.16; 'received:211.29.132': 0.16; 'received:cskk.homeip.net': 0.16; 'received:homeip.net': 0.16; 'received:optusnet.com.au': 0.16; 'received:syd.optusnet.com.au': 0.16; 'simpson': 0.16; 'why,': 0.16; 'exception': 0.16; 'so.': 0.16; 'wrote:': 0.18; 'do.': 0.18; 'print': 0.22; 'header:User-Agent:1': 0.23; 'recognize': 0.24; 'cheers,': 0.24; 'script': 0.25; 'header:In-Reply-To:1': 0.27; 'unix': 0.29; 'strongly': 0.30; "skip:' 10": 0.31; 'pipe': 0.31; 'probably': 0.32; 'everyone': 0.33; 'totally': 0.33; "i'd": 0.34; 'could': 0.34; 'something': 0.35; 'operate': 0.35; 'but': 0.35; 'machine.': 0.36; 'received:com.au': 0.36; 'skip:> 10': 0.36; 'two': 0.37; 'received:211': 0.38; 'to:addr:python-list': 0.38; 'explain': 0.39; 'to:addr:python.org': 0.39; '8bit%:6': 0.40; 'even': 0.60; 'read': 0.60; 'skip:\xc2 10': 0.60; 'john': 0.61; "you're": 0.61; 'content-disposition:inline': 0.62; 'account': 0.65; 'finish': 0.65; 'physics': 0.68; 'superior': 0.69; 'special': 0.74; '*and*': 0.84; 'mechanics': 0.84; 'clique': 0.91 Date: Sat, 18 Oct 2014 18:11:45 +1100 From: Cameron Simpson To: python-list@python.org Subject: Re: Flush stdin MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) References: X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.1 cv=fvDlOjIf c=1 sm=1 tr=0 a=YuQlxtEQCowy2cfE5kc7TA==:117 a=YuQlxtEQCowy2cfE5kc7TA==:17 a=ZtCCktOnAAAA:8 a=PO7r1zJSAAAA:8 a=LcaDllckn3IA:10 a=r5UFkecV8NkA:10 a=IkcTkHD0fZMA:10 a=vrnE16BAAAAA:8 a=pGLkceISAAAA:8 a=2_IPBEs8TFvmUo_RCwwA:9 a=QEXdDO2ut3YA:10 a=MSl-tDqOz04A:10 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: 43 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1413616320 news.xs4all.nl 2900 [2001:888:2000:d::a6]:52712 X-Complaints-To: abuse@xs4all.nl X-Received-Body-CRC: 2072735937 X-Received-Bytes: 4980 Xref: csiph.com comp.lang.python:79261 On 17Oct2014 12:38, Empty Account wrote: >I am using netcat to listen to a port and python to read stdin and print to >the console. > >nc -l 2003 | python print_metrics.py > >sys.stdin.flush() doesn’t seem to flush stdin, so I am using the termios >module.  You're aware that a stdio flush and a termios flush operate on two totally unrelated buffers? >while True:  >   input = sys.stdin.readline() >   # do some parsing  >   …   >   sys.stdout.write(parsed_data) >   time.sleep(3) >   termios.tcflush(sys.stdin, termios.TCIOFLUSH) > >I am receiving this exception >termios.error: (25, 'Inappropriate ioctl for device') That is because stdin is attached to the pipe from netcat. A pipe is not a terminal. >I will be using this script on Unix based systems and I wondered what >approach I could use  >to flush stdin? Like Chris, I think you need to explain why you even want to flush stdin. There's probably something better you can do. Cheers, Cameron Simpson I strongly suspect so. Practically everyone on sci.physics has a theory that is far superior to special relativity, general relativity, quantum mechanics *and* the standard model. Around here, it's only a small clique of arrogant young members of the physics establishment who fail to recognize these revolutionary theories. I'd explain why, but I have to go finish designing my faster-than-light vacuum energy perpetual motion telekinetic aether-powered time machine. - John Baez