Dennis Lee Bieber wrote: > > I'm not sure why you need to subclass from threading.Thread if all > the thread control is being done internal to this class. Subclassing > means being able to do things like: > Well it was the first thing that occured to me how to have private data for each thread ( IP, PORT , CURDIR if I decide to serve files. ) although I did come across some private_data CLASS in the docs.
> mySH = client_socket_handler(some, args) > ... > mySh.start() hope I can call self.start() from __init__() or self.socket_handler() > > ... ie; instances of your class behave just like an extended instance of > the Thread class; but the user of this class never sees that it IS a > thread. I believe the other facet is that when subclassing from Thread, > one overloads the run() method AS the target instead of passing some > other function as a target argument and letting the parent run() method > call it. > > > So why not just make the thread an attribute of the class instead. > > Maybe that would be clearer. Starting to wonder if I could return thread name this way, then again, I think part reason for this aproach was the fact that once started it could finish/crash all on it's lonesome and it's instance could wait for garbage collection. >> 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() > > Which is about what you were doing here, but should have used > self.t1 =... > self.t1.start() > Well this shouldn't realy be here just stuff I pasted over. Which brings me to a question how to start my thread internaly. Once I managed to call __init__() I should be able to call self.start() nicht var? or is it vahr? >> 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 ): > > You aren't passing any arguments to this method. > >> 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") > > What do you expect the behavior to be if a new-line is embedded and > not adjacent to a carriage return? > oops: #handle macs self.socket.send( "500 Inferior systems not permited.\r\n" ) self.socket.close() Heh. Besides I don't think NL is permisible as line separator. the command is at the beginnign and I don't expect to support any multitude of tags. -- http://mail.python.org/mailman/listinfo/python-list