def run(self):
        s = self.source
        t = self.target
        cs = self.chunk_size
        ccm = self.chunk_count_max
        kr = self.keep_reading
        da = self.data_added
        go = self.go

        try:
            b = s.read(cs)
        except __HOLE__:
            b = ''

        while b and go.is_set():
            if len(t) > ccm:
                kr.clear()
                kr.wait(2)
#                # this only works on 2.7.x and up
#                if not kr.wait(10):
#                    raise Exception("Timed out while waiting for input to be read.")
                # instead we'll use this
                if len(t) > ccm + 3:
                    raise IOError("Timed out while waiting for input from subprocess.")
            t.append(b)
            da.set()
            b = s.read(cs)
        self.EOF.set()
        da.set()  # for cases when done but there was no input.
dataset/ETHPy150Open codeinn/vcs/vcs/subprocessio.py/InputStreamChunker.run