(self, *args, **kwargs)
Initializes a ThreadPoolServer. In particular, instantiate the thread pool.
Initializes a ThreadPoolServer. In particular, instantiate the thread pool.
Initializes a ThreadPoolServer . In particular instantiate the thread pool .
def __init__(self, *args, **kwargs):
        '''Initializes a ThreadPoolServer. In particular, instantiate the thread pool.'''
        # get the number of threads in the pool
        nbthreads = 20
        if 'nbThreads' in kwargs:
            nbthreads = kwargs['nbThreads']
            del kwargs['nbThreads']
        # get the request batch size
        self.request_batch_size = 10
        if 'requestBatchSize' in kwargs:
            self.request_batch_size = kwargs['requestBatchSize']
            del kwargs['requestBatchSize']
        # init the parent
        Server.__init__(self, *args, **kwargs)
        # a queue of connections having somethign to process
        self._active_connection_queue = Queue.Queue()
        # declare the pool as already active
        self.active = True
        # setup the thread pool for handling requests
        self.workers = []
        for _ in range(nbthreads):
            t = threading.Thread(target = self._serve_clients)
            t.setName('ThreadPoolWorker')
            t.daemon = True
            t.start()
            self.workers.append(t)
        # a polling object to be used be the polling thread
        self.poll_object = poll()
        # a dictionary fd -> connection
        self.fd_to_conn = {}
        # setup a thread for polling inactive connections
        self.polling_thread = threading.Thread(target = self._poll_inactive_clients)
        self.polling_thread.setName('PollingThread')
        self.polling_thread.setDaemon(True)
        self.polling_thread.start()
def __init__ ( self , * args , * * kwargs ) : # get the number of threads in the pool nbthreads = 20 if 'nbThreads' in kwargs : nbthreads = kwargs [ 'nbThreads' ] del kwargs [ 'nbThreads' ] # get the request batch size self . request_batch_size = 10 if 'requestBatchSize' in kwargs : self . request_batch_size = kwargs [ 'requestBatchSize' ] del kwargs [ 'requestBatchSize' ] # init the parent Server . __init__ ( self , * args , * * kwargs ) # a queue of connections having somethign to process self . _active_connection_queue = Queue . Queue ( ) # declare the pool as already active self . active = True # setup the thread pool for handling requests self . workers = [ ] for _ in range ( nbthreads ) : t = threading . Thread ( target = self . _serve_clients ) t . setName ( 'ThreadPoolWorker' ) t . daemon = True t . start ( ) self . workers . append ( t ) # a polling object to be used be the polling thread self . poll_object = poll ( ) # a dictionary fd -> connection self . fd_to_conn = { } # setup a thread for polling inactive connections self . polling_thread = threading . Thread ( target = self . _poll_inactive_clients ) self . polling_thread . setName ( 'PollingThread' ) self . polling_thread . setDaemon ( True ) self . polling_thread . start ( )