def stream_read(pipe):
    """Read data from the pipe."""
    buffer = getattr(pipe, 'buffer', pipe)
    header = buffer.read(4)
    if not header:
        raise StreamEmpty

    if len(header) < 4:
        raise StreamError('Incorrect byte length')

    length = struct.unpack('I', header)[0]
    data = buffer.read(length)
    if len(data) < length:
        raise StreamError('Got less data than expected')
    return pickle.loads(data)
dataset/ETHPy150Open zchee/deoplete-jedi/rplugin/python3/deoplete/sources/deoplete_jedi/server.py/stream_read/original