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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started