()
| 3286 | return None |
| 3287 | |
| 3288 | def run_add_or_renew_pool(): |
| 3289 | try: |
| 3290 | if self._protocol_version >= 3: |
| 3291 | new_pool = HostConnection(host, distance, self) |
| 3292 | else: |
| 3293 | # TODO remove host pool again ??? |
| 3294 | new_pool = HostConnectionPool(host, distance, self) |
| 3295 | except AuthenticationFailed as auth_exc: |
| 3296 | conn_exc = ConnectionException(str(auth_exc), endpoint=host) |
| 3297 | self.cluster.signal_connection_failure(host, conn_exc, is_host_addition) |
| 3298 | return False |
| 3299 | except Exception as conn_exc: |
| 3300 | log.warning("Failed to create connection pool for new host %s:", |
| 3301 | host, exc_info=conn_exc) |
| 3302 | # the host itself will still be marked down, so we need to pass |
| 3303 | # a special flag to make sure the reconnector is created |
| 3304 | self.cluster.signal_connection_failure( |
| 3305 | host, conn_exc, is_host_addition, expect_host_to_be_down=True) |
| 3306 | return False |
| 3307 | |
| 3308 | previous = self._pools.get(host) |
| 3309 | with self._lock: |
| 3310 | while new_pool._keyspace != self.keyspace: |
| 3311 | self._lock.release() |
| 3312 | set_keyspace_event = Event() |
| 3313 | errors_returned = [] |
| 3314 | |
| 3315 | def callback(pool, errors): |
| 3316 | errors_returned.extend(errors) |
| 3317 | set_keyspace_event.set() |
| 3318 | |
| 3319 | new_pool._set_keyspace_for_all_conns(self.keyspace, callback) |
| 3320 | set_keyspace_event.wait(self.cluster.connect_timeout) |
| 3321 | if not set_keyspace_event.is_set() or errors_returned: |
| 3322 | log.warning("Failed setting keyspace for pool after keyspace changed during connect: %s", errors_returned) |
| 3323 | self.cluster.on_down(host, is_host_addition) |
| 3324 | new_pool.shutdown() |
| 3325 | self._lock.acquire() |
| 3326 | return False |
| 3327 | self._lock.acquire() |
| 3328 | self._pools[host] = new_pool |
| 3329 | |
| 3330 | log.debug("Added pool for host %s to session", host) |
| 3331 | if previous: |
| 3332 | previous.shutdown() |
| 3333 | |
| 3334 | return True |
| 3335 | |
| 3336 | return self.submit(run_add_or_renew_pool) |
| 3337 |
nothing calls this directly
no test coverage detected