Let's say I have classes where I define attributes as getter/setter. Classes are like this one:
class TestClass:
def __init__(self):
self.name = "default name"
@property
def myname(self):
self._myname = self.name
return self._myname
@myname.setter
def myname(self, n):
self._myname = n
self.name = self._myname
I instance these classes. In this example I instance several times this same class:
a = TestClass()
a.myname = "A"
b = TestClass()
b.myname = "B"
Setting and getting these names requires a certain amount of time.
How can I get in parallel a.myname
and b.myname
?
How can I set in parallel a.myname = "new A"
and b.myname = new B
?
The examples that I saw here, here, here and here with multiprocessing
, multithreading
only involve functions or standard class methods.
Moreover, a solution based on ray
apparently does not allow to access class attributes.