Re: at-exit-thread



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

Diez
.



Relevant Pages

  • Re: Is it possible to run two "while 1:" loops in two threadings respectively?
    ... second threading never be started. ... def tcpip: ... Or you don't subclass Thread and pass a target. ...
    (comp.lang.python)
  • Re: challenge
    ... ara.t.howard@xxxxxxxx schrieb: ... ~> cat a.rb ... def File.open42 end ... ~> ruby a.rb ...
    (comp.lang.ruby)
  • Re: Execute commands from file
    ... "Steve Holden" schrieb ... and you will see NameError raised because the assignment ... def sowhat: ... SyntaxError: unexpected EOF while parsing ...
    (comp.lang.python)
  • Re: Python and threads
    ... vedrandekovic@xxxxxxxxx schrieb: ... def run: ... Even if you managed to get two threads started simultaneously (which the OS doesn't even offer IINM), the would soon run out of sync. ...
    (comp.lang.python)
  • Re: help me~!about base64
    ... ylj798@xxxxxxxxx schrieb: ... import base64 ... def deflashget: ... elif st.startswithor st.startswith: ...
    (comp.lang.python)