What is the "correct" way of detecting and handling an exception in another thread in Python, when the code in that other thread is not under your control?
For instance, say you set a function that requires 2 parameters as the target of the threading.Thread
object, but at runtime attempt to pass it 3. The Thread
module will throw an exception on another thread before you can even attempt to catch it.
Sample code:
def foo(p1,p2):
p1.do_something()
p2.do_something()
thread = threading.Thread(target=foo,args=(a,b,c))
thread.start()
Throws an exception on a different thread. How would you detect and handle that?