def communicate(self, input=None):
        """Interact with process: Send data to stdin. Read data from stdout and stderr, until end-of-file is reached. Wait for process to terminate. The optional input argument should be a string to be sent to the child process, or None, if no data should be sent to the child."""
        rfs = []
        wfs = []
        ex = []
        if self.stdout is not None:
            stdoutdata = ""
            rfs.append(self.stdout)
        else:
            stdoutdata = None
        if self.stderr is self.stdout:
            seo = True
        else:
            seo = False
            if self.stderr is not None:
                stderrdata = ""
                rfs.append(self.stderr)
            else:
                stderrdata = None
        if (self.stdin is not None) and (input is not None):
            wfs.append(self.stdin)

        while len(rfs + wfs) > 0:
            tr, tw, he = select.select(rfs, wfs, ex)
            if self.stdin in tw:
                if len(input) < 4096:
                    self.stdin.write(input)
                    input = ""
                    wfs.remove(self.stdin)
                else:
                    self.stdin.write(input[:4096])
                    input = input[4096:]
            if self.stderr in tr:
                data = self.stderr.read(4096)
                if not data:
                    rfs.remove(self.stderr)
                else:
                    stderrdata += data
            if self.stdout in tr:
                data = self.stdout.read(4096)
                if not data:
                    rfs.remove(self.stdout)
                else:
                    stdoutdata += data

        if seo:
            return (stdoutdata, stdoutdata)
        else:
            return (stdoutdata, stderrdata)
Interact with process: Send data to stdin. Read data from stdout and stderr, until end-of-file is reached. Wait for process to terminate. The optional input argument should be a string to be sent to the child process, or None, if no data should be sent to the child.
lib/mlpatches/modules/subprocess.py