Re: at-exit-thread



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.
.



Relevant Pages

  • Re: Quicksort
    ...     int p, child, parent; ... Sort routine cr88192c works remarkably well on distributions with a ... 3.329000 qsort interface, heapsort, down and up ... hsort5: 3.892000 heapsort siftup ...
    (comp.programming)
  • Re: errrr...ooops. I wont say much here.
    ... no spec or selection for different types and alloys of pipe, ...   On inquiry thats not going to change anytime soon. ... tutorials, and skip the goal of teaching 38 things in one video. ... it took a day to sort out which one was appropriate for what mode I ...
    (comp.cad.solidworks)
  • Re: 1 in 20 UK schoolchildren thought Hitler was coach of a German football team
    ... the sort of bullshit we have had to listen to for decades. ... war even to this day. ...      No, that's all you had because you were broke. ... liberated other occupied European nations these would have added to the ...
    (soc.culture.scottish)
  • Re: 1 in 20 UK schoolchildren thought Hitler was coach of a German football team
    ... That sort of line of yours above is just exactly the sort of thing ... war even to this day. ... Euros couldn't resolve. ...
    (soc.culture.scottish)
  • Re: Unintentionally Sympathetic Villains
    ... stable rule in postwar Everytown, at what appears to be a higher ...  The Boss, oddly enough, considers this to be some sort ... However, I think it was the Wandering Sickness, not the Sleeping ...
    (rec.arts.sf.written)