I post this small reproducible example of the issue I'm trying to solve. I'm using the multiproccessing python module and I want to print a string on the console, but nothing appears. If you execute the function without multiprocessing is working though.
import multiprocessing as mp
def print_works(a):
print(f"it works {a}")
if __name__ == "__main__":
l=[1,2,3]
p = mp.Pool(processes=1)
p.map(print_works, l)
p.close()
The result I want to obtain is:
it works 1
it works 2
it works 3
If you execute the function in a for loop it works:
l=[1,2,3]
for i in l:
print_works(i)
The result is the one I want to obtain:
it works 1
it works 2
it works 3
Note: This is a silly example of the functionality I want to implement. I'm using Python 3.6.8, Windows 10 and VS Code editor.