Python multiprocessing class methods

Viewed 22754

I'm trying to change a class field using it's method, but when the method is put into it doesn't work.

from multiprocessing import Process

class Multi:
    def __init__(self):
        self.x = 20


    def loop(self,):
        for i in range(1,100):
            self.x = i

M = Multi()

p = Process(target=M.loop)
p.start()

After running this program M.x is still 20. How is that possible?

1 Answers
Related