I want to use sharing state with ProcessPoolExecutor
Code:
from multiprocessing import Value
from concurrent.futures import ProcessPoolExecutor
def function(times, a):
print('I\'m here')
for _ in range(times):
with a.get_lock():
a.value += 1
def main():
a = Value('I', 0, lock=True)
with ProcessPoolExecutor(max_workers=5) as executor:
for i in range(5):
executor.submit(function, 1000000, a)
print("----------------------", a.value)
main()
But it stucks and don't even prints 'I'm here'