Re: at-exit-thread
- From: castironpi@xxxxxxxxx
- Date: Fri, 29 Feb 2008 12:12:13 -0800 (PST)
On Feb 29, 1:55 pm, "Diez B. Roggisch" <de...@xxxxxxxxxxxxx> wrote:
castiro...@xxxxxxxxx schrieb:
The Python main interpreter has an at-exit list of callables, which
are called when the interpreter exits. Can threads have one? What's
involved, or is the best way merely to subclass Thread?
Is that some sort of trick-question?
class MyThread(Thread):
def run(self):
while some_condition:
do_something()
do_something_after_the_thread_ends()
The atexit stuff is for process-termination which is/may be induced by
external signals - which is the reason why these callbacks extist.
Threads don't have that, thus no need.
That depends. If a thread adds an object it creates to a nonlocal
collection, such as a class-static set, does it have to maintain a
list of all such objects, just to get the right ones destroyed on
completion? Processes destroy their garbage hassle-free; how can
threads? And don't forget Thread.run( self ) in the example, if
anyone ever wants to make use of the 'target' keyword.
.
- Follow-Ups:
- Re: at-exit-thread
- From: castironpi
- Re: at-exit-thread
- References:
- at-exit-thread
- From: castironpi
- Re: at-exit-thread
- From: Diez B. Roggisch
- at-exit-thread
- Prev by Date: Re: at-exit-thread
- Next by Date: Re: joining strings question
- Previous by thread: Re: at-exit-thread
- Next by thread: Re: at-exit-thread
- Index(es):
Relevant Pages
|