Re: safest way to kill a thread

2005-01-19 Thread martinnitram
Thank for all helping and sorry that i overlooked the previous message. Peter Hansen wrote: > [EMAIL PROTECTED] wrote: > > Should the 'daemonic' flag at setDaemon() function set to 1/TRUE or > > 0/FALSE to do such action? > > First of all, it's "True" and "False" in Python, not TRUE > and FALSE. >

Re: safest way to kill a thread

2005-01-19 Thread hoxide
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 . -- http://mail.python.org/mailman/listinfo/python-

Re: safest way to kill a thread

2005-01-19 Thread martinnitram
Great thank for your helping. Should the 'daemonic' flag at setDaemon() function set to 1/TRUE or 0/FALSE to do such action? limodou wrote: >I think only those threads which invoked with setDaemon() method will >exit, and others will not, as the main program exit. -- http://mail.python.org/mail

Re: safest way to kill a thread

2005-01-18 Thread limodou
I think only those threads which invoked with setDaemon() method will exit, and others will not, as the main program exit. [EMAIL PROTECTED] wrote: limodou wrote: Using Thread's method setDaemon() before you call the start() method. Just like : t.setDaemon(True) t.start() thank for fast reply. f

Re: safest way to kill a thread

2005-01-18 Thread martinnitram
limodou wrote: >Using Thread's method setDaemon() before you call the start() method. >Just like : >t.setDaemon(True) >t.start() thank for fast reply. from python.org doc, said that setDaemon() function as "The entire Python program exits when no active non-daemon threads are left." is it mean that

Re: safest way to kill a thread

2005-01-18 Thread limodou
Using Thread's method setDaemon() before you call the start() method. Just like : t.setDaemon(True) t.start() [EMAIL PROTECTED] wrote: Dear all, in python, a thread can be created by t = threading.Thread. But i found that when the main (and the thread) program is running and user use Crtl+C/Crtl+

safest way to kill a thread

2005-01-18 Thread martinnitram
Dear all, in python, a thread can be created by t = threading.Thread. But i found that when the main (and the thread) program is running and user use Crtl+C/Crtl+Z to break the program abnormally, the thread is still running and needed to kill manually (by the pid). Is there had any safest way to k