The idea im trying to run is this:
RUN 3 Processes doing calculation ONCE one of the 3 processes finishes the task KILL others imediatly and continue with the main task, i can't let it run any second longer
The things i've tried was: Putting the global variable through multiprocessing.manager, but that still lets processes finish their loops. Raising an exception
OS: Windows PYTHON: 2.7
def f(name):
Doing = True
try:
while Doing:
print 'DOING',name
somecodethatmarksDoingAsFalse()
except Exception as error:
print 'bye'
print error
Doing = False
return True
if __name__ == '__main__':
p = multiprocessing.Process(target=f, args=('bob',))
p2 = multiprocessing.Process(target=f, args=('tom',))
p.start()
p2.start()
p.join()
p2.join()
raise Exception('I know Python!')
sys.exit()
I expect to be able to kill all processes when i mark doing as false, raise an exception or any way when calculation is done on ONE of the processes
EDIT: It's not a duplicate, because it still finishes executing code, for example Requests module still sends data