Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #79254

Flush stdin

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 <emptya45@gmail.com>
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 <emptya45@gmail.com>
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 <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.14954.1413612650.18130.python-list@python.org> (permalink)
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

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

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’t seem to flush stdin, so I am using the termios
module.

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')


I will be using this script on Unix based systems and I wondered what
approach I could use
to flush stdin?

Many Thanks

Aidy

Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Flush stdin Empty Account <emptya45@gmail.com> - 2014-10-17 12:38 +0100
  Re: Flush stdin Nobody <nobody@nowhere.invalid> - 2014-10-18 17:55 +0100
    Re: Flush stdin Tim Chase <python.list@tim.thechases.com> - 2014-10-18 12:32 -0500
      Re: Flush stdin Nobody <nobody@nowhere.invalid> - 2014-10-19 02:11 +0100
        Re: Flush stdin Dan Stromberg <drsalists@gmail.com> - 2014-10-18 18:34 -0700
        Re: Flush stdin Dan Stromberg <drsalists@gmail.com> - 2014-10-18 18:42 -0700
          Re: Flush stdin Nobody <nobody@nowhere.invalid> - 2014-10-22 03:49 +0100
            Re: Flush stdin Dan Stromberg <drsalists@gmail.com> - 2014-10-21 20:11 -0700
    Re: Flush stdin MRAB <python@mrabarnett.plus.com> - 2014-10-18 18:55 +0100
    Re: Flush stdin Cameron Simpson <cs@zip.com.au> - 2014-10-19 08:01 +1100
    Re: Flush stdin Terry Reedy <tjreedy@udel.edu> - 2014-10-18 18:35 -0400

csiph-web