Python's multiprocessing.Pool process global scope problem
问题 How can I change a global variable STOP to True ? As I understand, the problem is with the scope of other processes, but I don't know how to realize it. from multiprocessing import Pool from time import sleep STOP = False def get_nums(state, block_size): pages = [i for i in range(state*block_size + 1, (state + 1)*block_size + 1)] return pages def square(x): sleep(1) if x == 19: global STOP STOP = True print(f'squared\t{x}') return x*x if __name__ == '__main__': state = 0 result = [] while not