def __encode_multithreaded(f, data):
    """The base function that runs the given function f in multithreaded
    fashion.

    :param f: The function
    :param data: The data
    :return:
    """
    import multiprocessing
    import platform
    number_of_threads = multiprocessing.cpu_count() / 2

    if platform.system() == 'Windows':
        multiprocessing.set_executable('C:/Python27/pythonw.exe')
    elif platform.system() == 'Linux':
        multiprocessing.set_executable('/usr/bin/python')

    p = multiprocessing.Pool(number_of_threads)

    number_of_chunks = len(data) // 4
    chunk_per_thread = number_of_chunks / number_of_threads
    split_per_char = chunk_per_thread * 4

    thread_data = []
    for i in range(0, len(data), split_per_char):
        thread_data.append(data[i:i + split_per_char])

    data = ''.join(p.map(f, thread_data))
    p.close()
    return data
dataset/ETHPy150Open eoyilmaz/anima/anima/render/arnold/base85.py/__encode_multithreaded/original