Can we raise exception in pool.starmap

Can we raise exception if a thread fails in pool.starmap if no what could be a way atound to catch it in catch block

Please provide code that demonstrates your issue.

My code below is able to catch an exception raised from a thread just fine:

from multiprocessing.dummy import Pool

def f(a, b):
    if a == 2:
        raise ValueError(a, b)
    return a + b
    print(Pool().starmap(f, zip(range(3), range(3))))
except ValueError as e:
    print('caught', e) # outputs: caught (2, 2)

def __fun(self, args) :
with ThreadPool(len(args)) as pool:
return pool.starmap(self.__sol, args)

Please provide a reproducible example. One that we can run directly.

Like in this code we are not able to know the threads where fault occurs

Please do not post code as a picture. Copy and paste your code as text into your posts instead so people can easily run it.

Similar code below outputs integer division or modulo by zero as expected:

from multiprocessing.pool import ThreadPool

def func(a, b):
    print(a // b, 'Hello')

with ThreadPool() as pool:
        print(pool.starmap(func, [(4, 2), (3, 0), (5, 6)]))
    except Exception as e:

Demo here