May I ask how can different process update the same dictionary in the concurrent.futures library? I understand that python built-in process does not talk with each other so what is the cannon way to get the process update the global dictionary? Here is a sample code
import concurrent.futures
quantity = {'apple': 0, 'pear': 0}
price = {'apple': 0, 'pear': 0}
args = [('apple', 1, 10), ('pear', 2,30)]
def update(args):
quantity[args[0]] = args[1]
price[args[0]] = args[2]
with concurrent.futures.ProcessPoolExecutor() as executor:
executor.map(update, args)
How can I get the executor to update the price
and quantity
dict? I tried to avoid ThreadPool since I do not know how to manage racing condition, which mess up a part of my project (I want to update a list and ThreadPool does not keep it in the order that I want).
Thank you very much