Question: I'm trying to run this code and it's giving this error... what is the solution for this problem? import collections import multiprocessing import os import
I'm trying to run this code and it's giving this error... what is the solution for this problem?
import collections import multiprocessing import os import time from pprint import pprint
Scientist = collections.namedtuple('Scientest', [ 'name', 'field', 'born', 'nobel', ]) scientists = ( Scientist(name = 'Ada Lovelace', field = 'math', born = '1815', nobel = False), Scientist(name = 'Emmy Noether', field = 'math', born = '188255', nobel = False), Scientist(name = 'Marie Curie', field = 'physics', born = '1867', nobel = True), Scientist(name = 'Tu Youyou', field = 'chemistry', born = '1930', nobel = True), Scientist(name = 'Ada Yonath', field = 'chemistry', born = '1939', nobel = True), Scientist(name = 'Vera Rubin', field = 'astronomy', born = '1928', nobel = False), Scientist(name = 'Sally Ride', field = 'physics', born = '1951', nobel = False), )
print(scientists) print()
def transform(x): print(f'Process {os.getegid()} working record {x.name}') time.sleep(1) result = {'name': x.name, age: 2023 - x.born} print(f'Process {os.getegid()} done processing record {x.name}') return result
start = time.time() pool = multiprocessing.Pool(processes= 3) result = pool.map(transform, scientists)
end = time.time() print(f' Time to complete: {end - start: .2f}s ') print(result)

Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
