Feb-09-2021, 01:11 PM
Hi guys,
I'm struggling to get the correct code configuration to update an integer variable across multi-process processes!
My code in brief is below:
The output in the final print statement is zero but I know this not to be the case.
Any ideas please?
I'm struggling to get the correct code configuration to update an integer variable across multi-process processes!
My code in brief is below:
import multiprocessing from multiprocessing import Value error_value = Value('i',0) #assign as integer type def get_data(url): try: ...code doing some stuff here except ValueError as e: #if error thrown up simply count it error_value.acquire() error_value.value += 1 error_value.release() pass if __name__ == '__main__': # ---- Perform multi-processing p = multiprocessing.Pool(6) results = p.map(get_data,'argslist') p.close() p.join() print(str(error_value.value))So in the first instance I just want to count the number of errors thrown up in the function.
The output in the final print statement is zero but I know this not to be the case.
Any ideas please?