Process Pool Worker Ignoring Global Variable Update
I have a function which I'm running using a concurrent.futures.ProcessPoolExecutor. The function looks up a key in a dictionary. The dictionary is a global variable. The functio
Solution 1:
It looks like the entire file gets re-ran for each subprocess. In those processes, __name__
is no longer equal to '__main__'
but rather '__mp_main__'
. Therefore, the code which added all of the keys to the dictionary wasn't being run.
I'll change my program to explicitly pass the global variable to the function as an argument since, in my actual code, it's costly to compute.
Post a Comment for "Process Pool Worker Ignoring Global Variable Update"