Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin1!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!news.tele.dk!news.tele.dk!small.news.tele.dk!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.105 X-Spam-Level: * X-Spam-Evidence: '*H*': 0.79; '*S*': 0.00; 'parsing': 0.09; 'python': 0.11; 'flush': 0.16; 'true:': 0.16; 'exception': 0.16; 'input': 0.22; 'print': 0.22; 'script': 0.25; 'unix': 0.29; 'message- id:@mail.gmail.com': 0.30; "skip:' 10": 0.31; 'could': 0.34; 'received:google.com': 0.35; '8bit%:9': 0.36; 'module.': 0.36; 'thanks': 0.36; 'hi,': 0.36; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'read': 0.60; 'skip:\xc2 10': 0.60; '\xc2\xa0\xc2\xa0': 0.74; '8bit%:24': 0.84; '\xe2\x80\xa6': 0.84 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=7+wvz+27Mc5jD3vmMA3tJtqgHY44MpF8TJemCPk3KBg=; b=re2+hKdh/a08t+eFs+3hAbB+Sk0jijPV2/c6Vd/C8PwK5hQCRGjfB4YuKMGo+ymyxp OeEy3EdsBWsAAgKEIR32HWVRfuAsrkV1/3JKM/SkmESQiMp4/5x3HeGQ0lCFMcWechV6 AUwE9WjP3iqWbh274yT9j5xYv8+N1ZIQMtyshdmoIc0GMLwZpvKmWRmhqlU6FGhsHTHE Saq3xLNtw8hvQDXYjKwhZoqt9XnRb79gH2ToMLo4G4jI9J2WSTXCdrOKU/gOI7wGp7xF OoQzTvstMWJAmEvKTFAj2q1j7HnyosVlo7FpRP+TLe6rQZpKhw6mDhU8qNXTj35hviTG pG3Q== MIME-Version: 1.0 X-Received: by 10.60.62.8 with SMTP id u8mr2456563oer.39.1413545934729; Fri, 17 Oct 2014 04:38:54 -0700 (PDT) Date: Fri, 17 Oct 2014 12:38:54 +0100 Subject: Flush stdin From: Empty Account To: python-list@python.org Content-Type: multipart/alternative; boundary=089e015382aa50356905059ccfc8 X-Mailman-Approved-At: Sat, 18 Oct 2014 08:10:49 +0200 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: 57 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1413612650 news.xs4all.nl 2847 [2001:888:2000:d::a6]:34682 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:79254 --089e015382aa50356905059ccfc8 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi, 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=E2=80=99t seem to flush stdin, so I am using the te= rmios module. while True: input =3D sys.stdin.readline() # do some parsing =E2=80=A6 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') I will be using this script on Unix based systems and I wondered what approach I could use to flush stdin? Many Thanks Aidy --089e015382aa50356905059ccfc8 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi,=C2=A0

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=E2=80=99t seem to flush stdin, so I am usin= g the termios module.=C2=A0

while True:=C2=A0
=C2=A0 =C2=A0input =3D sys.stdin.readline()
=C2=A0 =C2=A0# = do some parsing=C2=A0
=C2=A0 =C2=A0=E2=80=A6 =C2=A0
=C2= =A0 =C2=A0sys.stdout.write(parsed_data)
=C2=A0 =C2=A0time.sleep(3= )
=C2=A0 =C2=A0termios.tcflush(sys.stdin, termios.TCIOFLUSH)


I am receiving this exception
termios.error: (25, 'Inappropriate ioctl for device')

I will be using this script on Unix based syste= ms and I wondered what approach I could use=C2=A0
to flush stdin?=

Many Thanks

Aidy

--089e015382aa50356905059ccfc8--