I can access and change the attributes of classes in a list like this:
class TestClass:
def __init__(self):
self.value = 1
instances = [TestClass()]
instances[0].value = 42
print(instances[0].value) # 42
However, when using the multiprocessing.Manager
, my code seems to be without any effect:
from multiprocessing import Manager
with Manager() as manager:
instances = manager.list([TestClass()])
instances[0].value = 42
print(instances[0].value) # 1
How to properly store an iterable with instances of a class using the multiprocessing
module?