Pickling error in multiprocessing

Good morning all. I’m trying to run a test example of multiprocessing in SageMath 10.3 on Jupyter. I get an error saying that the lookup for the function “task” failed. I’m a bit new to this, and am wondering where I’m going wrong. Is there a package I forgot to install or something? Thanks. Eric

PicklingError: Can’t pickle <function task=“” at=“” 0x15676bc40=“”>: attribute lookup task on sage.all_cmdline failed

reset()
from random import random
from time import sleep
from multiprocessing.pool import Pool


def task(identifier):
    # generate a value
    value = random()
    # report a message
    print(f'Task {identifier} executing with {value}', flush=True)
    # block for a moment
    sleep(value)
    # return the generated value
    return value

def eric():
    # create and configure the process pool
    with Pool() as pool:
        # execute tasks in order, process results out of order
        for result in pool.imap_unordered(task, range(50)):
            print(f'Got result: {result}', flush=True)

eric()