Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #79261 > unrolled thread
| Started by | Cameron Simpson <cs@zip.com.au> |
|---|---|
| First post | 2014-10-18 18:11 +1100 |
| Last post | 2014-10-18 18:11 +1100 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Flush stdin Cameron Simpson <cs@zip.com.au> - 2014-10-18 18:11 +1100
| From | Cameron Simpson <cs@zip.com.au> |
|---|---|
| Date | 2014-10-18 18:11 +1100 |
| Subject | Re: Flush stdin |
| Message-ID | <mailman.14960.1413616320.18130.python-list@python.org> |
On 17Oct2014 12:38, Empty Account <emptya45@gmail.com> 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 <cs@zip.com.au> 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
Back to top | Article view | comp.lang.python
csiph-web