I have two processing running that access an imported module like that:
import foo
def bar():
while True:
foo.a = True
def baz():
while True:
print foo.a
p1 = Process(target=bar)
p2 = Process(target=baz)
p1.start()
p2.start()
It seems that each process have their own instance of module foo, bar()
changes value to True, but in baz()
it's False. Any workaround?
queue
s andpipe
sProcess
mean a real process (ie with separate memory space)? In that case it's expected that they have own instances of modules. What do you want to do? Communicate? In the documentation it says how to do that (queues, pipes and shared memory).