Exemplo n.º 1
0
 def create_pool(
         self,
         pair=(client_context.host, client_context.port),
         *args,
         **kwargs):
     # Start the pool with the correct ssl options.
     pool_options = client_context.client._topology_settings.pool_options
     kwargs['ssl_context'] = pool_options.ssl_context
     kwargs['ssl_match_hostname'] = pool_options.ssl_match_hostname
     return Pool(pair, PoolOptions(*args, **kwargs))
 def create_pool(
         self,
         pair=(client_context.host, client_context.port),
         *args,
         **kwargs):
     # Start the pool with the correct ssl options.
     pool_options = client_context.client._topology_settings.pool_options
     kwargs['ssl_context'] = pool_options.ssl_context
     kwargs['tls_allow_invalid_hostnames'] = pool_options.tls_allow_invalid_hostnames
     kwargs['server_api'] = pool_options.server_api
     pool = Pool(pair, PoolOptions(*args, **kwargs))
     pool.ready()
     return pool
Exemplo n.º 3
0
    def test_max_pool_size_with_connection_failure(self):
        # The pool acquires its semaphore before attempting to connect; ensure
        # it releases the semaphore on connection failure.
        test_pool = Pool(('somedomainthatdoesntexist.org', 27017),
                         PoolOptions(max_pool_size=1,
                                     connect_timeout=1,
                                     socket_timeout=1,
                                     wait_queue_timeout=1))

        # First call to get_socket fails; if pool doesn't release its semaphore
        # then the second call raises "ConnectionFailure: Timed out waiting for
        # socket from pool" instead of AutoReconnect.
        for i in range(2):
            with self.assertRaises(AutoReconnect) as context:
                with test_pool.get_socket({}, checkout=True):
                    pass

            # Testing for AutoReconnect instead of ConnectionFailure, above,
            # is sufficient right *now* to catch a semaphore leak. But that
            # seems error-prone, so check the message too.
            self.assertNotIn('waiting for socket from pool',
                             str(context.exception))
 def get_pool(self, *args, **kwargs):
     kwargs['use_greenlets'] = self.use_greenlets
     return Pool(*args, **kwargs)
Exemplo n.º 5
0
 def create_pool(self, pair=(host, port), *args, **kwargs):
     return Pool(pair, PoolOptions(*args, **kwargs))
Exemplo n.º 6
0
 def create_pool(self,
                 pair=(client_context.host, client_context.port),
                 *args,
                 **kwargs):
     return Pool(pair, PoolOptions(*args, **kwargs))