In ParallelPython, a method of an object ( object.func() ) fails to manipulate a variable of an object ( object.value )

Posted by mehmet.ali.anil on Stack Overflow See other posts from Stack Overflow or by mehmet.ali.anil
Published on 2012-03-30T10:34:39Z Indexed on 2012/03/30 11:29 UTC
Read the original article Hit count: 399

Filed under:
|
|
|

With parallelpython, I am trying to convert my old serial code to parallel, which heavily relies on objects that have methods that change that object's variables. A stripped example in which I omit the syntax in favor of simplicity:

class Network:
    self.adjacency_matrix = [ ... ]
    self.state = [ ... ]
    self.equilibria = [ ... ]

...

   def populate_equilibria(self):
       # this function takes every possible value that self.state can be in
       # runs the boolean dynamical system 
       # and writes an integer within self.equilibria for each self.state
       # doesn't return anything

I call this method as: Code:

j1 = jobserver.submit(net2.populate_equilibria,(),(),("numpy as num"))

The job is sumbitted, and I know that a long computation takes place, so I speculate that my code is ran.

The problem is, i am new to parallelpython , I was expecting that, when the method is called, the variable net2.equilibria would be written accordingly, and I would get a revised object (net2) . That is how my code works, independent objects with methods that act upon the object's variables.

Rather, though the computation is apparent, and reasonably timed, the variable net2.equilibria remains unchanged. As if PP only takes the function and the object, computes it elsewhere, but never returns the object, so I am left with the old one.

What do I miss?

Thanks in advance.

© Stack Overflow or respective owner

Related posts about python

Related posts about oop