I don't see many posts about the @parallel decorator, but I'm having
a problem that I would think would be pretty common.  I want to
decorate a function that performs some action with an instantiated
class and returns the results of that class method, but when I try
to execute the generator returned from the decorated function, I get
an
error that the 'global' class cannot be found.

Here's an example:

class foo():
     def do_something(self, myargs):
          return myargs

@parallel()
def f(N):
     a = foo()
     return a.do_something(N)

g=f([1,2,3,4])
list(g)

---------------------------------------------------------------------------
NameError                                 Traceback (most recent call
last)

/home/jlh/<ipython console> in <module>()

/usr/local/sage-3.4.1/local/lib/python2.5/site-packages/sage/parallel/
multiprocessing.pyc in parallel_iter(processes, f, inputs)

/usr/local/sage-3.4.1/local/lib/python2.5/site-packages/processing/
pool.pyc in next(self, timeout)

NameError: global name 'foo' is not defined
sage:


So anyway, the only examples I've found of sage + @parallel use
functions that
don't instantiate a user class.  They just use like def f(N):  return
N^2 and so on.
Thanks for any pointers to docs or examples that might help me use
this decorator.

Thanks,

J
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to