0

I have a following question: Consider flowing data through pipe to python script and processing it there line by line. The rate of lines of text going to the pipe is very fast (sys.stdin.readline ), and what if lines of text are coming too fast for script to handle, what happens then? Will stdin read lines in order or the newest one?

1 Answer 1

3

The pipe is managed by the operating system: One process writes to the pipe, the OS buffers what was written and passes it on to the reading process. If the buffer of the pipe is full, subsequent write operations of the writing process will simply block until there is enough space in the buffer again.

So in short, the OS makes sure nothing gets lost, and you don't have to worry about it.

2
  • And what should I do to get always newest data?
    – stuudent
    Feb 21, 2012 at 15:47
  • 1
    @stuudent: I don't really understand that question. You might want to ask a new question, detailing what you are trying to achieve. Feb 21, 2012 at 15:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.