threads and sys.exit()
robert
no-spam at no-spam-no-spam.com
Mon Apr 24 15:59:14 EDT 2006
gangesmaster wrote:
> calling sys.exit() from a thread does nothing... the thread dies, but
> the interpreter remains. i guess the interpreter just catches and
> ignore the SystemExit exception...
>
> does anybody know of a way to overcome this limitation?
>
call thread.interrupt_main()
on *NIX: os.kill(os.getpid(),signal.XXXX)
or best design your threading correctly with resonable/flexible
communication channels, e.g. CallQueue:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/491281
(infact that latter (example2) uses sys.exit/SystemExit the other way
correctly: to terminate a thread cleanly in functional style. in the
same style reverse the mainthread could be terminated cleanly.)
I'd
-robert
More information about the Python-list
mailing list