diff --git a/rpyc/utils/server.py b/rpyc/utils/server.py index 2079ffd6..c7374510 100644 --- a/rpyc/utils/server.py +++ b/rpyc/utils/server.py @@ -317,15 +317,8 @@ class ThreadPoolServer(Server): def __init__(self, *args, **kwargs): '''Initializes a ThreadPoolServer. In particular, instantiate the thread pool.''' # get the number of threads in the pool - self.nbthreads = 20 - if 'nbThreads' in kwargs: - self.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'] + self.nbthreads = kwargs.pop('nbThreads', 20) + self.request_batch_size = kwargs.pop('requestBatchSize', 10) # init the parent Server.__init__(self, *args, **kwargs) # a queue of connections having something to process @@ -476,11 +469,7 @@ def _authenticate_and_build_connection(self, sock): # authenticate if self.authenticator: h, p = sock.getpeername() - try: - sock, credentials = self.authenticator(sock) - except AuthenticationError: - self.logger.warning("%s:%s failed to authenticate, rejecting connection", h, p) - return None + sock, credentials = self.authenticator(sock) else: credentials = None # build a connection @@ -496,16 +485,12 @@ def _accept_method(self, sock): # authenticate and build connection object conn = self._authenticate_and_build_connection(sock) # put the connection in the active queue - if conn: - h, p = sock.getpeername() - fd = conn.fileno() - self.logger.debug("Created connection to %s:%d with fd %d", h, p, fd) - self.fd_to_conn[fd] = conn - self._add_inactive_connection(fd) - self.clients.clear() - else: - self.logger.warning("Failed to authenticate and build connection, closing %s:%d", h, p) - sock.close() + h, p = sock.getpeername() + fd = conn.fileno() + self.logger.debug("Created connection to %s:%d with fd %d", h, p, fd) + self.fd_to_conn[fd] = conn + self._add_inactive_connection(fd) + self.clients.clear() except Exception: h, p = sock.getpeername() self.logger.exception("Failed to serve client for %s:%d, caught exception", h, p)