worker thread catching exceptions and putting them in queue

Aahz aahz at pythoncraft.com
Thu Mar 8 11:31:14 EST 2007


In article <45ec4936$0$323$e4fe514c at news.xs4all.nl>,
Paul Sijben  <paul.sijben at xs4all.nl> wrote:
>
>in a worker thread setup that communicates via queues is it possible to
>catch exceptions raised by the worker executed, put them in an object
>and send them over the queue to another thread where the exception is
>raised in that scope?
>
>considering that an exception is an object I feel it ought to be
>possible, however I do not see how to go about it.

One caution: because exceptions keep stack frames alive, you can have
garbage collection problems.  Make sure to del the exception when you're
done with it.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"I disrespectfully agree."  --SJM



More information about the Python-list mailing list