access to base class __init__

castironpi at gmail.com castironpi at gmail.com
Thu Mar 6 04:38:52 CET 2008


On Mar 5, 6:09 pm, sambo q <sa... at voidstar.com> wrote:
> 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__()
> ??

recall a= A() --> a.b() --> A.b( a ).  What is A?  threading.Thread.

In other words, threading.Thread.__init__( *stuff ).



More information about the Python-list mailing list