I am using threading.Thread(target, *args, **k)
from the Python threading library:
t = Thread(
target=self.connect,
args=(
hostname,
username,
password,
pre_name,
config_data,
action,
post_name),
kwargs=key_value
)
When I call t.start()
- it executes the function in the target, but if the values are wrong or the device is not available - the thread will throw an exception, and the system will hang.
I get the following traceback:
Exception in thread Thread-2:
Traceback (most recent call last):
File "C:\Python27\lib\threading.py", line 801, in __bootstrap_inner
self.run()
File "C:\Python27\lib\threading.py", line 754, in run
self.__target(*self.__args, **self.__kwargs)
the connect
function called in a particular thread is throwing an exception -which is not being identified by its parent thread.
How can the rest of my program know of this exception (so I can handle it)?