def shutdown(self, c): ''' Shutdown this process ''' try: try: util.debug('manager received shutdown message') c.send(('#RETURN', None)) if sys.stdout != sys.__stdout__: util.debug('resetting stdout, stderr') sys.stdout = sys.__stdout__ sys.stderr = sys.__stderr__ util._run_finalizers(0) for p in active_children(): util.debug('terminating a child process of manager') p.terminate() for p in active_children(): util.debug('terminating a child process of manager') p.join() util._run_finalizers() util.info('manager exiting with exitcode 0') except: import traceback traceback.print_exc() finally: exit(0)
def main(): initialize() game = setup_game() with mp.Manager() as manager: exc = manager.Queue() arg_list = [] for i in range(0, 3): arg_list.append(((i, i + 3), game, False, exc)) arg_list.append(((5, 5), game, True, exc)) proc_list = [] for arg in arg_list: proc_list.append(mp.Process(target=function, args=arg)) proc_list[-1].start() print("Number of active children post start: %d" % len(mp.active_children())) for p in proc_list: p.join() if (not exc.empty()): e = exc.get() print(e.message) print("Number active children post join: %d " % len(mp.active_children())) print(mp.active_children()) print(mp.current_process())
def main(): initialize() game = setup_game() with mp.Manager() as manager: exc = manager.Queue() arg_list = [] for i in range(0, 3): arg_list.append( ((i, i+3), game, False, exc)) arg_list.append( ((5, 5), game, True, exc)) proc_list = [] for arg in arg_list: proc_list.append(mp.Process(target=function, args=arg)) proc_list[-1].start() print("Number of active children post start: %d" % len(mp.active_children())) for p in proc_list: p.join() if(not exc.empty()): e = exc.get() print(e.message) print("Number active children post join: %d " % len(mp.active_children())) print(mp.active_children()) print(mp.current_process())
def kill_threads(): for thread in active_children(): thread.terminate()