If Subprocess.PIPE is buffered, then there will be several items in stdin when got the stop message. The timeout to wait for Queue must be at least  time used to process the items in the buffer of stdout.