I have 2 threads, Thread A and Thread B.
Thread A takes data from either sys.stdin or from the read end of a pipe (using os.pipe()). Whatever data gets read (from either sys.stdin or from the read end of the pipe) gets sent out on a TCP socket. Thread A uses select.select() to determine whether it should read from sys.stdin or from the read end of the pipe, and select.select() is using a 1 second timeout to periodically check and make sure that the socket connection is still there.
Thread B holds the write end of the pipe, and will typically just write 1 really long string to the pipe, and then close the write end.
How can Thread A check for an EOF on the pipe? Basically, I want Thread A to close the pipe when it's no longer being used. But, I can't risk blocking on read() from the pipe, because then data that is available on sys.stdin would be unnecessarily blocked.
Any help would be greatly appreciated. Thank you!