First time here? Check out the FAQ!

Ask Your Question
1

NameError: name '...' is not defined

asked 2 years ago

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?

Preview: (hide)

Comments

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

Max Alekseyev gravatar imageMax Alekseyev ( 2 years ago )

1 Answer

Sort by » oldest newest most voted
2

answered 2 years ago

slelievre gravatar image

updated 1 year ago

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,)]))
Preview: (hide)
link

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: 2 years ago

Seen: 1,520 times

Last updated: Dec 05 '23