stuudent
stuudent

Reputation: 350

python pipe (stdin) too fast

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?

Upvotes: 0

Views: 661

Answers (1)

Sven Marnach
Sven Marnach

Reputation: 602575

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.

Upvotes: 3

Related Questions