access to base class __init__

sambo q sambo at voidstar.com
Thu Mar 6 01:09:44 CET 2008


I got myself in jam trying to be too fancy with  threading.Thread
Docs say / remind to call the base __init__
but I can't fighure out how.

---------------------------
def main()
.....
    ls.listen(5)
    key = ' '
#    while key != EXITCHARCTER:
    while stop_serving == False:
        cs, raddr = ls.accept()
        print "Main_Thread: ",cs, raddr
        nt = client_socket_handler( cs, raddr )
        print threading.enumerate()
        key = getkey()
        
#    ls.close()
    time.sleep(4)
    print "Server Exiting."

class client_socket_handler(threading.Thread):
    def __init__(self, cs, remote_address):
???????????????????????
        self.threading.Thread.__init__(self,self.socket_handler,None,None)
        self.socket = cs
        self.rhost_addr = remote_address
        print "client_socket_handler.__init__(): ", self.socket, 
self.rhost_addr
#        t1 = threading.Thread( None,self.socket_handler, None, (5,78) )
#        t1.start()
        self.start()
        print "client_socket_handler.__init__(): ", self.socket, 
self.rhost_addr
        print "client_socket_handler.__init__(): enumerate()", 
threading.enumerate()
        
    def socket_handler( self, invar, indict ):
        threadname = self.getName()
        print "\"%s started\"" % threadname
        print "client_socket_handler.socket_handler() invar: ", invar
        instr = self.socket.recv( 500 )
#        print instr
        req_lines = string.split( instr, "\r" )
        for line in req_lines:
            line.strip( "\n")
        print req_lines
        print len( instr )

----------------------------------

self.threading.Thread.__init__()
self.Thread.__init__()
??



More information about the Python-list mailing list