I did some googling and it sounds like it doesn't matter if write blocks, because the GIL will release and other threads can run while this thread blocks.

http://docs.python.org/2/c-api/init.html#thread-state-and-the-global-interpreter-lock

>Therefore, the rule exists that only the thread that has acquired the GIL may operate on Python objects or call Python/C API functions. In order to emulate concurrency of execution, the interpreter regularly tries to switch threads (see sys.setcheckinterval()). The lock is also released around potentially blocking I/O operations like reading or writing a file, so that other Python threads can run in the meantime.

The PIPE_BUF stuff I found in the subprocess communicate() method, but it turns out that writing PIPE_BUF is only guaranteed to be non-blocking after a poll() or select().  We probably should write in small chunks anyway and PIPE_BUF seems good enough.

This method could be something like this...  (untested)


```python
    @staticmethod
    def _string_stdin_drainer(input_string, stdin_pipe):
        """
        input is a string and output is PIPE
        """
        try:
            while True:
                # we can write PIPE_BUF bytes without blocking after a poll or select
                # we aren't doing either but let's write small chunks anyway.
                # POSIX requires PIPE_BUF is >= 512
                tmp = input_string[:select.PIPE_BUF]
                if tmp == '':
                    break
                stdin_pipe.write(tmp)
                input_string = input_string[select.PIPE_BUF:]
        finally:
            # close reading PIPE so that the reader doesn't block
            stdin_pipe.close()
```