How do I access the return values of ThreadPoolExecutor?
10,429
I don't know where your alist and blist variables are coming from, but you could do something like this.
def func(a,b):
return (func2(a),func3(3))
def paralel_func(alist, blist):
processes = []
with ThreadPoolExecutor(max_workers=None) as executor:
processes.append(executor.map(func, alist, blist))
for _ in concurrent.futures.as_completed(processes):
print('Result: ', _.result())
Author by
zython
BSc Computer Science Student from 2015-2018 (hopefully) hoping learn some stuff and pursue a carrer in CS
Updated on June 05, 2022Comments
-
zython almost 2 years
Say I have the following code:
def func(a,b): return (func2(a),func3(3)) def paralel_func(alist,blist) with ThreadPoolExecutor(max_workers=None) as executor: executor.map(func,alist,blist)
How do I access the return values that were returned from
func
? I tried to figure it out myself by thinking thatexecutor.map
is a list that holds the values but that didnt work for me. -
zython about 6 yearswouldnt I have to loop over
alist
andblist
to submit the futures ? -
joe hoeller about 2 yearsIncomplete answers that do not show full scope are insuffcient. Where is number, prime and PRIMES defined at?