My code works perfectly on Windows, but on macOS, it throws a RuntimeError. Here’s a simplified version of my code:
import multiprocessing as mp
def worker(num):
"""worker function"""
print(f'Worker: {num}')
return num * num
if __name__ == '__main__':
with mp.Pool(processes=4) as pool:
results = pool.map(worker, range(10))
print(results)
New contributor
somayyeh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.