How to get a raised exception from other thread

Peter Hansen peter at engcorp.com
Sat Oct 15 11:58:05 EDT 2005


dcrespo wrote:
> How can I get a raised exception from other thread that is in an
> imported module?

Define what "get" means for your purposes.  It appears that you mean you 
want to catch the exception, but in the thread which launched the other 
thread in the first place.  If that's true, please show where you would 
expect to catch this exception, given that when you start the thread, 
the main thread continues running and might even finish before the other 
thread finishes.

> thread = programB.MakeThread()
> thread.start()
...
# later code which might have completed by the time the thread finishes
...

Are you looking, for example, for some kind of
thread.waitUntilCompletionAndReRaiseExceptions() method?

-Peter



More information about the Python-list mailing list