Q: Multicore Processing Python dosent print the output of a function I don't understand why is the reason that the code dosen't print the output in console of this very fool programm.
import numpy as np
from multiprocessing import Process

def calc2(nucleo, tope):
    for i in range(0, tope):
        print(str(np.sqrt(i)) + "  el nucleo es  " + str(nucleo))


processes = []

for i in range(os.cpu_count()):
    print("registering process %d" % i)
    processes.append(Process(target=calc2, args=(i, 100, )))

for process in processes:
    process.start()

for process in processes:
    process.join()


A: As for how to get return values, here is one option
import os
import numpy as np
import multiprocessing as mp

def calc2worker(args):
    return calc2(*args)

def calc2(nucleo, tope): 
    return ["{} el nucleo es {}".format(np.sqrt(i), nucleo)
        for i in range(0, tope)]

if __name__ == "__main__":
    pool = mp.Pool() # defaults to os.cpu_count()
    data_generator = ((i, 100) for i in range(os.cpu_count()))
    for result in pool.map(calc2worker, data_generator):
        for line in result:
            print(line)
    pool.close()

