I have done a task of concurrent in Python, as the following code
def fun_x(a, b) :
for x in range(10000) :
x = x*x
for y in range(10000) :
y = y*y
return a*x, b*y
with futures.ProcessPoolExecutor() as executor:
futures_all_data = {executor.submit(fun_x, # Function name
number_a, # args 1
number_b, # args 2
) : number_a
for number_a, number_b in arg }
output_final = {}
for future in futures.as_completed(futures_all_data, timeout = None) :
result_Code, result_content = future.result()
output_final[result_Code] = result_content
return output_final
Currently, I need to use and class and a subfunction instead of funx, like,
def class_x(object):
__init__(self, a):
for x in range(10000):
x = x*x
a = a*x
def fun_y(self, b) :
for y in range(10000):
y = y*y
b = y*b + a
However, I am not sure how to deal with the executor.submit part?
Could you give me some guidance?
Thank you so much!