Python multiprocessing pool get integer identifying call -


import multiprocessing      def func():         # print call index         pass      p = multiprocessing.pool(4)     p.map(func, data) 

in above code, possible print in func(), integer identifying number of times has been called 0, 1...

i want because there code in func() want execute once, , cannot moved outside of func()

what want involves sharing state between processes -- can hairy in python. if don't think can restructure program avoid it, multiprocessing has of useful synchronization constructs threading module: https://docs.python.org/2/library/multiprocessing.html#synchronization-between-processes. sounds maybe need lock , shared memory.


Popular posts from this blog