Joel VanderWerf
8/28/2007 7:59:00 PM
MenTaLguY wrote:
> On Wed, 29 Aug 2007 03:33:04 +0900, Joel VanderWerf <vjoel@path.berkeley.edu> wrote:
>> It's just one of those gotchas that keeps coming up. A similar one is
>>
>> Thread.abort_on_exception = true
>>
>> (otherwise threads die silently on unhandled exceptions).
>
> You don't always want to do that, since you can recover the unhandled
> exception that terminated a thread via Thread#join or Thread#value
> and some libraries rely on this.
Good point. It's a global setting, so should be avoided. Better to set
this flag on threads individually using the instance method
#abort_on_exception and do so only in those cases where you don't use
join or value to propagate the exception to another thread. For example,
it would be a good idea to set this flag for a thread that is expected
to run indefinitely (no other thread is waiting for it to finish). Even
in that case, you might want to wrap the thread's code in a rescue
clause, if you just want to log the error and let other threads proceed.
--
vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407