Python Forum
multiprocess passing multiple arguments double asterisk - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: multiprocess passing multiple arguments double asterisk (/thread-605.html)



multiprocess passing multiple arguments double asterisk - pic8690 - Oct-22-2016

import multiprocessing as mp

def bar(**kwargs):
   for a in kwargs:
      print a,kwargs[a]

arguments={'name':'Joe','age':20}
p=mp.Pool(processes=4)
p.map(bar,**arguments)
p.close()
p.join()
Errors:

Traceback (most recent call last):
  File "post.py", line 9, in <module>
    p.map(bar,**arguments)
TypeError: map() got an unexpected keyword argument 'age'

How do I pass the dictionary arguments?

Thank you,


RE: multiprocess passing multiple arguments double asterisk - Skaperen - Oct-23-2016

just don't pass an argument.  with multiprocessing it forks whole process copies that inherit all the virtual memory.  so each subprocess will have its own copy of all the data the parent had.  if you need to pass data the other way, from child to parent, learn about pipes and files.