passing arguments to tcpserver classes

Eric Spaulding els24 at cornell.edu
Wed Jun 13 10:19:51 EDT 2007


Is there an easy way to pass arguments to a handler class that is used 
by the standard TCPServer?

normally --> srvr =SocketServer.TCPServer(('',port_num), TCPHandlerClass)

I'd like to be able to: srvr =SocketServer.TCPServer(('',port_num), 
TCPHandlerClass, (arg1,arg2))

And have arg1, arg2 available via TCPHandlerClass.__init__ or some other 
way.

Where TCPHandlerClass:

class TCPHandlerClass(SocketServer.StreamRequestHandler):
    def handle(self):
       #handle stream events here#


Thanks for any advice.




More information about the Python-list mailing list