c6ed366dda201c889c46839fddcbc81214afd025,horovod/run/common/util/safe_shell_exec.py,,forward_stream,#Any#Any#Any#Any#,59

Before Change


def forward_stream(src_fd, dst_stream, prefix, index):
    with os.fdopen(src_fd, "r") as src:
        while True:
            line = src.readline()
            if not line:
                break

            if index is not None:

After Change


    with os.fdopen(src_fd, "r") as src:
        line_buffer = ""
        while True:
            text = os.read(src.fileno(), 1000)
            if not isinstance(text, str):
                text = text.decode("utf-8")
            if not text:
                break

            for line in re.split("([\r\n])", text):
                line_buffer += line
                if line == "\r" or line == "\n":
                    if index is not None:
                        localtime = time.asctime(time.localtime(time.time()))
                        line_buffer = "{time}[{rank}]<{prefix}>:{line}".format(
                            time=localtime,
                            rank=str(index),
                            prefix=prefix,
                            line=line_buffer
                        )

                    dst_stream.write(line_buffer)
                    dst_stream.flush()
                    line_buffer = ""


def execute(command, env=None, stdout=None, stderr=None, index=None, event=None):
    // Make a pipe for the subprocess stdout/stderr.
    (stdout_r, stdout_w) = os.pipe()
    (stderr_r, stderr_w) = os.pipe()
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 5

Instances


Project Name: horovod/horovod
Commit Name: c6ed366dda201c889c46839fddcbc81214afd025
Time: 2019-08-14
Author: taddair@uber.com
File Name: horovod/run/common/util/safe_shell_exec.py
Class Name:
Method Name: forward_stream


Project Name: senarvi/theanolm
Commit Name: 04229ae7c14ebdbc043831e5ffe47a561dcdf31c
Time: 2015-10-16
Author: seppo.git@marjaniemi.com
File Name: theanolm/iterators.py
Class Name: BatchIterator
Method Name: __len__


Project Name: pysb/pysb
Commit Name: 31bedbc4d8d62fc42a7c9a20dd51c372cb510447
Time: 2017-05-02
Author: ben.gyori@gmail.com
File Name: pysb/kappa.py
Class Name:
Method Name: _parse_kasim_outfile