I've been trying to print to screen stuff from the process spawned by Pool. Unfortunately nothing comes up! I need this, as I'll have 4 processes running at the same time for quite a long, and I need to get some estimated and print some information meanwhile.
I've been browsing around trying to figured out by myself, but I haven't understand if this is really possible or how to do it. Using Process rather than Pool? Any help & code will be really appreciated!
Here is a very simple example I'll be happy to make it work!
from multiprocessing import Pool
import os
def printer(i):
pid = os.getpid()
print "#%i PID: %i" % (i,pid)
return pid
if __name__ == '__main__':
pool = Pool(2)
res = pool.map(printer,[1,2])
pool.terminate()
print "PIDs", res
I would like this to print what "printer" does before terminate the pool and print "res".