Changeset 177 for pykoticon/trunk/bin

Show
Ignore:
Timestamp:
01/26/07 21:23:40 (18 years ago)
Author:
jerome
Message:

Now accepts several concurrent requests.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykoticon/trunk/bin/pykoticon

    r176 r177  
    4141import xmlrpclib 
    4242import SimpleXMLRPCServer 
     43import SocketServer 
     44 
    4345try : 
    4446    import optparse 
     
    8890Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.""" 
    8991 
    90          
    91 class MyXMLRPCServer(SimpleXMLRPCServer.SimpleXMLRPCServer) : 
     92 
     93class ThreadedXMLRPCServer(SocketServer.ThreadingTCPServer, SimpleXMLRPCServer.SimpleXMLRPCDispatcher) : 
     94    """Base class to have a threaded XMLRPC Server.""" 
     95    def __init__(self, addr, requestHandler=SimpleXMLRPCServer.SimpleXMLRPCRequestHandler, logRequests=False) : 
     96        """Imitate what is in SimpleXMLRPCServer.py but with a threaded TCP server instead.""" 
     97        self.logRequests = logRequests 
     98        SimpleXMLRPCServer.SimpleXMLRPCDispatcher.__init__(self) 
     99        SocketServer.ThreadingTCPServer.__init__(self, addr, requestHandler) 
     100         
     101class MyXMLRPCServer(ThreadedXMLRPCServer) : 
    92102    """My own server class.""" 
    93103    allow_reuse_address = True 
    94104    def __init__(self, frame, options, arguments) : 
    95         SimpleXMLRPCServer.SimpleXMLRPCServer.__init__(self, \ 
    96                                                        ('0.0.0.0', options.port), \ 
    97                                                        SimpleXMLRPCServer.SimpleXMLRPCRequestHandler, \ 
    98                                                        options.debug) 
     105        ThreadedXMLRPCServer.__init__(self, \ 
     106                                      ('0.0.0.0', options.port), \ 
     107                                      SimpleXMLRPCServer.SimpleXMLRPCRequestHandler, \ 
     108                                      options.debug) 
    99109        self.frame = frame 
    100110        self.debug = options.debug