Back in September 2007 I was sitting with dipesh until late in the night on a very interesting problem:
We wanted to implement a "tee"-like class in python which would work as the same command under unix: get input via one stream, double the input and give it out into a file and into a stream (like sys.stdout). This shouldn't be a big problem but when you try to give this class to subprocess.Popen as one of the streams you will find out that Popen doesn't use the write function but instead uses the fileno() function of the fileobject. But there would be a workaround for that:
We use subprocess.PIPE for the wanted input stream, then we check regularly for any stuff within the pipe - that this will not work on windows one could expect.
The problem is that all available read processes will block execution if not enough bytes can be read.
The solution is called pywin32 and is a python package for windows. Mark Hammond from starship has made them and they include a function called PeekNamedPipe which does exactly what we need: peek into the pipe without blocking it. I should leave the rest as a homework to the reader, but for those who don't want to invest any more research, I'll give a first solution from where you can start (look at the class Popen).