Error occuring in multiprocessing.Pool()

asked 2024-12-11 17:25:05 +0100

AKGSage gravatar image

updated 2024-12-11 18:46:45 +0100

I'm trying to learn multiprocessing in SageMath and I picked this wonderful example notebook to try things out. I have been working out and playing with things step by step and I tried the multiprocessing part today.

I defined the following part, exactly as defined in the notebook,

display(f)
pool = multiprocessing.Pool(n_cpu)
for i, some_res in enumerate(pool.imap_unordered(calc_some_geodesics, args)): # do and wait
    # progress bar update
    f.value += len(some_res)
    # update result
    geo.update(some_res)

# clean exit
pool.close()
pool.join()

But when I run this, it gives me the following error,

MaybeEncodingError: Error sending result: '<multiprocessing.pool.ExceptionWithTraceback object at 0x7fd960bdf400>'. Reason: 'TypeError("cannot pickle 'sage.cpython.getattr.AttributeErrorMessage' object")'

I surfed through the web and I am seeing some ways of fixing this error but I'm not sure how to do it in my case. Any help to resolve this error would be really great, Cheers!

Edit: I also found a couple of other forum questions (this one,and this one) all related to the same multiprocessing module in the same notebook, is it something that cannot be fixed? Please guide me, cheers!

edit retag flag offensive close merge delete

Comments

The example notebook works well for me with SageMath 10.5 running on Ubuntu 24.04. Which version of Sage are you using and what is your operating system?

eric_g gravatar imageeric_g ( 2024-12-11 23:12:16 +0100 )edit

I'm using sage version 10.2 on Ubuntu 22.04 WSL on Windows 11. I will try to restart the kernel and re-run all the code again to check what is going wrong.

AKGSage gravatar imageAKGSage ( 2024-12-12 07:26:56 +0100 )edit