def socket_recvall(socket, length, bufsize=4096):
    """A helper method to read of bytes from a socket to a maximum length"""
    data = b""
    while len(data) < length:
        data += socket.recv(bufsize)
    return data
dataset/ETHPy150Open borntyping/python-riemann-client/riemann_client/transport.py/socket_recvall/original