def callback(p):
    ofd = p.stdout.fileno()
    efd = p.stderr.fileno()
    while True:
        r_ready, w_ready, x_ready = select.select([ofd, efd], [], [], 30)

        if r_ready in ofd:
            data = os.read(ofd, 8192)
            if not data:
                break
            yield data

        if efd in r_ready:
            data = os.read(efd, 8192)
            yield data
            break

    output, err = p.communicate()
    if output:
        yield output
        if err:
            yield err
dataset/ETHPy150Open douban/gpack/ghttp.py/callback/swapped operands of `in`