I'm using spyder 5.1.5 and I am trying to follow along with the very first example on a website. I'm getting the error:
AttributeError: Can't get attribute 'task' on <module '__main__' (built-in)>
task is a function that I define.
Full example code:
import multiprocessing
import time
def task(num):
print("a",num)
time.sleep(2)
if __name__ == '__main__':
for i in range(10):
p = multiprocessing.Process(target=task,args=(i,))
p.start()