threads and sys.exit()
robert
no-spam at no-spam-no-spam.com
Mon Apr 24 16:42:01 EDT 2006
gangesmaster wrote:
> that's not a question of design. i just want a child-thread to kill the
> process. in a platform agnostic way.
>
the clean kill is the 'KeyboardInterrupt'. your code finalizations are
at least done corretly. thats also raised on SIGINT by default.
so thread.interrupt_main() is that thing to go for on this level - lets
say on mid level.
killing hard (SIGKILL etc ) is low level. it should be OS-specific, as
Python should not make itself inconsistent
a good consistent killing on high level can only be done by inter-thread
communication - as shown in this recipe above. even if a
KeyboardInterrupt is thrown, like with ..
#raises SystemExit inside my_thread
cq.call(sys.exit, wait=1, raise_exception=2)
.. its thrown exactly app-deterministic a callqueue.receive() time.
so you have all levels and tools available. If you really miss
something, then I'd still say, the design question should be raised.
-robert
PS: SystemExit / sys.exit (doc: "Exit from Python"!?) is
misleading/historic. Its in fact almost "ThreadExit".
More information about the Python-list
mailing list