Skip to content Skip to sidebar Skip to footer

Identifying Thread Running Function Using Concurrent.futures Thread Pool In Python3

I have the following code: import concurrent.futures def f(a, b): print('Thread x => '+a+' '+b) with concurrent.futures.ThreadPoolExecutor(max_workers=3) as executor: f

Solution 1:

Did you mean to pass x as a parameter?

import concurrent.futures

def f(x, a, b):
    print("Thread”, x, “=>"+a+" "+b)

with concurrent.futures.ThreadPoolExecutor(max_workers=3) as executor:
   for n in executor.map(lambda n: f(n, 'abcd', 'xpto'), range(3)):
      pass

Post a Comment for "Identifying Thread Running Function Using Concurrent.futures Thread Pool In Python3"