python client server multithreaded

Why are the threads dying when I run this program? Since I am only calling “start” method,they should not be killed right? Or am I missing something else here?

host=raw_input("Enter the host name")
HOST=socket.gethostbyname(host)   
PORT=input("Enter the port no......") # specific port available

class procThread(threading.Thread):
    def __init__(self,ID):
        threading.Thread.__init__(self)
        self.ID=ID

    def run(self):
            try:
                s=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
                print 'Socket created' 
                s.connect((HOST,PORT))
                s.send('29298000280A81D72B150314234153026368560793189500000394F88FD18FFFFF0000001E0000000000000A0D')
                t=s.recv(1024)
                t=t.decode('ascii')
                f.write(t+'n')

            except Exception:
                print ("Sorry   ")


a=[]
for i in range(1,10):
    a.append(procThread(i))

for k in a:
    k.start()


Source: python

Leave a Reply