threads and exception in wxPython

Josiah Carlson jcarlson at uci.edu
Tue Nov 2 18:18:34 CET 2004


Zunbeltz Izaola <zunbeltz at wm.lc.ehu.es.XXX> wrote:
> I've an wxPython windows that creates a thread. An object of this
> thread raised an exception and i want to cach it in the main thread,
> that of the windows (I want this becouse the first implementation
> doesn't use thread). I know that exception can not be pass between 
> thread.
> 
> I've read something about wraping the run() method of the threaded 
> object in a try/except block and save the exception for inspection ,
> but i don't know how to implement it. Can you give me and advice?

from StringIO import StringIO
import traceback
import Queue

traceback_queue = Queue.Queue()

...
    def run(self):
        try:
            ...
        except:
            tb = StringIO()
            traceback.print_exc(tb)
            traceback_queue.put(tb.getvalue())
...


 - Josiah




More information about the Python-list mailing list