views:

53

answers:

2

how can i control the return value of this function pool apply_asyn supposing that I have the following cool

import multiprocessing:


de fun(..)
...
...
return value


my_pool = multiprocessing.Pool(2)


for i in range(5) :
    result=my_pool.apply_async(fun, [i])

 some code going to be here....

digest_pool.close()
digest_pool.join()
here i need to proccess the results 

how can i control the result value for every proccess and know to check to which proccess it belongs ,

A: 

store the the value of 'i' from the for loop and either print it or return and save it somewhere else. so if a process happens you can check from which process it was by looking at the variable i.

Hope this helps.

Pavan
A: 

Check out this thread, it should help you get information about the running threads. http://stackoverflow.com/questions/919897/how-to-find-a-thread-id-in-python

Vijay Selvaraj
Thanks but i use proccesses and not threads
AKM