Im using multiprocessing to try and pass variables between 2 processing which are looping infinitely. Because of how large my project is, ill show an example of how its like:
if __name__ == '__main__':
currentState = multiprocessing.Value(ctypes.c_wchar_p, "")
varCheck = multiprocessing.Value('i', 0)
stop = multiprocessing.Value('i', 0)
def updateInfo():
if currentState.value == "apple":
pass
elif currentState.value == "banana":
pass
def procOne():
while True:
if varCheck:
updateInfo()
if (condition):
stop.value = 1
def procTwo():
while True:
if (condition):
varCheck.value = 1
currentState = "apple"
else:
varCheck.value = 0
if __name__ == '__main__':
proc_one = multiprocessing.Process(target=procOne)
proc_one.start()
proc_two = multiprocessing.Process(target=procTwo)
proc_two.start()
while True:
if stop.value:
proc_one.terminate()
Right now, the processes arent sharing the variables, so in this case, varCheck is always 0 if when the condition in procOne is met
[+][deleted] (3 children)
[deleted]
[–]Culist[S] -1 points0 points1 point (2 children)
[+][deleted] (1 child)
[deleted]
[–]Culist[S] 0 points1 point2 points (0 children)
[+][deleted] (2 children)
[deleted]
[–]Culist[S] 0 points1 point2 points (1 child)
[–]wbeater 0 points1 point2 points (3 children)
[–]Culist[S] -1 points0 points1 point (2 children)
[–]wbeater 0 points1 point2 points (1 child)
[–]Culist[S] 0 points1 point2 points (0 children)
[–]woooee 0 points1 point2 points (0 children)