I am experiencing with Python Multiprocessing and got stuck with passing a list of object as pool.map arguments. The following codes print [None, None] instead of actual names. Can anybody shed some light on it?
from multiprocessing import Pool
class Item:
def __init__(self, firstname, lastname):
self.firstname = firstname
self.lastname = lastname
def get_items():
items = []
names = ['Joe Smith', 'Rick Harvard']
for name in names:
item = Item(name.split(' ')[0], name.split(' ')[1])
items.append(item)
return items
def f(name):
print(name.firstname, name.lastname)
if __name__ == '__main__':
p = Pool(16)
print(p.map(f, get_items()))
p.close()
p.join()
def f(...two times anddef f(...return two timesNone.print(name....indef f(...did not show up?