python - Fetch data returned by worker -


how can fetch data returned worker here??

import multiprocessing  def worker():        """worker function"""       return 'data'  if __name__ == '__main__':        jobs = []       in range(5):           p = multiprocessing.process(target=worker)           print p           jobs.append(p)           p.start() 

output :

data data data data data 

you can make pool of workers , pass in data process:

import multiprocessing  def worker(item):     return item ** 2  if __name__ == '__main__':     pool = multiprocessing.pool(5)      result in pool.imap_unordered(worker, range(30)):         print result 

Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -