Re: What happens to a thread with an unhandled exception?
- From: Frank Millman <frank@xxxxxxxxxxxx>
- Date: Fri, 29 Jun 2007 07:31:18 -0700
On Jun 29, 2:51 pm, Frank Millman <f...@xxxxxxxxxxxx> wrote:
Hi all[...]
I am doing something which works, but I have a gut feel that it cannot
be relied upon. Can someone confirm this one way or the other.
My worry is that the thread with the unhandled exception may
eventually get garbage-collected, in which case the cleanup method
will no longer be accessible. Could this happen, or does the thread
stay in memory until termination of the main program?
I just noticed Diez's reply to a related question earlier today, where
he suggested wrapping the thread's run() method in a try/finally
construct. It works perfectly in my situation - if there is an
unhandled exception, my cleanup method is called before the exception
is raised. Thanks, Diez (even though you did not realise you were
helping me).
Frank
.
- References:
- What happens to a thread with an unhandled exception?
- From: Frank Millman
- What happens to a thread with an unhandled exception?
- Prev by Date: Re: Python's "only one way to do it" philosophy isn't good?
- Next by Date: Re: Set builtin lookups
- Previous by thread: What happens to a thread with an unhandled exception?
- Next by thread: How to close a program I execute with subprocess.Popen?
- Index(es):