Passing Exceptions Across Threads
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.python archive

Passing Exceptions Across Threads

From: Adam Mullins <adam.l.m@gmail.com>
Date: Wed Apr 26 2006 - 07:15:55 CEST

Hello, I'm writing a physics simulator back-end with a built-in,
threaded server that for the moment is quite simple. I've faced a few
problems in writing this code, however, as it's the first time I've
played with threading. For the moment, everything works decently, but I
need (or rather, want) a method for passing caught exceptions in
sub-threads to the main thread to be raised there. Although this
solution isn't the only one, I feel it will be the most elegant (the
thread/class will be called inside the main module within a try/except
structure, which makes the program a bit more modular, in my opinion,
and cleaner).

Here is my code so far:
http://rafb.net/paste/results/UESOWB24.html

You can see near the top where I clumsily tried to a hack a function
into threading._MainThread, in the hopes that if it were called from a
sub-thread it would execute in the main thread. This is seemingly not
so.

Many thanks for any help.
Received on Mon May 1 00:19:08 2006