safest way to kill a thread

hoxide hoxide_dirac at yahoo.com.cn
Wed Jan 19 07:10:16 EST 2005


To Catch the "SystemExit"

import thread
from time import sleep
import sys

def t1():
try:
i=0
while 1:
print i+1
i += 1
sleep(1)
except SystemExit:
pass

thread.start_new_thread(t1, ())
sleep(3)


This Question was also asked in Python-chinese .




More information about the Python-list mailing list