One common way to handle this is Popen.communicate potentially with a timeout.
In general “read” without a size in CPython reads in a loop until it hits an “End Of File” marker (read returns size zero). input() is also a read and in specific a readline looking for a newline marker. If you add a \n to the proc.stdin.write(b'hello\n') it will find the newline and continue / exit (which would also likely eliminate the hang).
The input() blocking for more data + proc.stdout.read() blocking for more data is what gives the “hang” / “deadlock” you see here. Both processes are waiting for data from the other but never send any. communicate in its implementation works to ensure that the subprocess doesn’t block on I/O and waits for process exit. For this case, it will close proc.stdin which will result in the subprocess seeing an end of line / input() in temp.py to finish even without a \n.
@Cody Maloney, @Chris Angelico, thank you for pointing out the missing b’\n’. What interested me is that once I was trapped into this situation by making a mistake, is there a way to escape from it instead of terminating the Windows cmd box?