I'm trying to change an external variable within a process but it is not working. I created a simple test class:
from multiprocessing import Process
class Classe():
def __init__(self, parent=None):
self.variavel="antes"
self.p = Process(target=self.f, args=(self.variavel,))
def f(self, variavel2):
variavel2="depois"
def g(self):
self.p.start()
self.p.join()
print self.variavel
teste=Classe()
teste.g()
But when I run this, it prints the old value of the variable, someone knows how to access a normal variable within the process, I tried to use self.variavel but it did not work too.