Ask Your Question
1

NameError: name '...' is not defined

asked 2022-08-19 12:10:33 +0200

Alex Karenin gravatar image

I got the preparsed with sage --preparse command keflll.py file with the function invertibles() that returns the list of integers. It doesn't use any lambda expressions. I can call it in the code, but as long as I try to call it in parallel i get the error:

NameError: name 'invertibles' is not defined

The code is given below:

from keflll import invertibles
from sage.parallel.multiprocessing_sage import pyprocessing

p_iter = pyprocessing(4)
P = parallel(p_iter=p_iter)
def f(x):    
    return invertibles(x)

list( P(f)([(2,),(3,)]) )

How can I parallelize calls of the functions that are in custom made module or just depend on those?

edit retag flag offensive close merge delete

Comments

Try to move from keflll import invertibles inside the definition of f.

Max Alekseyev gravatar imageMax Alekseyev ( 2022-08-19 13:24:55 +0200 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2022-08-19 14:51:37 +0200

slelievre gravatar image

updated 2023-12-05 15:45:48 +0200

Not sure if that would help, but the relevant import could be made part of the function that is being called in parallel.

Something like the following:

from sage.parallel.multiprocessing_sage import pyprocessing

p_iter = pyprocessing(4)
P = parallel(p_iter=p_iter)

def f(x):
    from keflll import invertibles
    return invertibles(x)

list(P(f)([(2,), (3,)]))
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2022-08-19 12:10:33 +0200

Seen: 998 times

Last updated: Dec 05 '23