[Tutor] How to kill a thread

Laura Creighton lac at openend.se
Sun Nov 22 06:54:39 EST 2015


In a message of Sun, 22 Nov 2015 11:23:58 +0530, CMG Thrissur writes:
>Hello,
>
>I have seen some examples of terminating a thread the safe way.  But is 
>there a way to kill a thread without worrying about what happens next. 
>Like thread.stop() or something
>
>George

import sys
sys.exit(1)

This will brutally kill the whole process.  Sometimes that is what you
want.  Most of the time, it isn't.  Python doesn't have a way to 
grab a thread and kill it, it can only ask it to please stop themselves.

Laura


More information about the Tutor mailing list