The call to sys.stdin.read()
blocks, as it is trying to read the entire stream, thus it can't return until the stream is closed.
Try using sys.stdin.readline()
and add a newline when writing using sys.stdout.write()
(in both processes), e.g. sys.stdout.write('ACK\n')
. This should make sure the reading commands will block only until a single line is read.