Re: thread end and make main program end also?

2005-03-10 Thread martinnitram
Sorry that i had't show my code clearly. The exception try and catch at the module function (i.e. myClass.myfunction(), which like: start code within myClass.py def myfunction(self, dbconnection): sql_query= 'update table set col=value' try: dbconnection.query(sql_query)

thread end and make main program end also?

2005-03-09 Thread martinnitram
Dear all, Following are some codes: from myClass import * # some user define classes, which will catch the exception within its function thread_function(): myClass myclass while (1): returnValue = myclass.myfunction(); print "Return Value %s" % returnValue

check socket alive

2005-02-07 Thread martinnitram
Dear all, following are some piece of my code (mainly create a socket connection to server and loop to receive data): # function to create and return socket def connect(): server_config = ('192.168.1.50', ); sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) try:

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 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 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

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