def add_execution_profile(self, name, profile, pool_wait_timeout=5):
        """
        Adds an :class:`.ExecutionProfile` to the cluster. This makes it available for use by ``name`` in :meth:`.Session.execute`
        and :meth:`.Session.execute_async`. This method will raise if the profile already exists.

        Normally profiles will be injected at cluster initialization via ``Cluster(execution_profiles)``. This method
        provides a way of adding them dynamically.

        Adding a new profile updates the connection pools according to the specified ``load_balancing_policy``. By default,
        this method will wait up to five seconds for the pool creation to complete, so the profile can be used immediately
        upon return. This behavior can be controlled using ``pool_wait_timeout`` (see
        `concurrent.futures.wait <https://docs.python.org/3/library/concurrent.futures.html#concurrent.futures.wait>`_
        for timeout semantics).
        """
        if not isinstance(profile, ExecutionProfile):
            raise TypeError("profile must be an instance of ExecutionProfile")
        if self._config_mode == _ConfigMode.LEGACY:
            raise ValueError("Cannot add execution profiles when legacy parameters are set explicitly.")
        if name in self.profile_manager.profiles:
            raise ValueError("Profile {} already exists".format(name))
        contact_points_but_no_lbp = (
            self._contact_points_explicit and not
            profile._load_balancing_policy_explicit)
        if contact_points_but_no_lbp:
            log.warning(
                'Tried to add an ExecutionProfile with name {name}. '
                '{self} was explicitly configured with contact_points, but '
                '{ep} was not explicitly configured with a '
                'load_balancing_policy. In the next major version, trying to '
                'add an ExecutionProfile without an explicitly configured LBP '
                'to a cluster with explicitly configured contact_points will '
                'raise an exception; please specify a load-balancing policy '
                'in the ExecutionProfile.'
                ''.format(name=repr(name), self=self, ep=profile))

        self.profile_manager.profiles[name] = profile
        profile.load_balancing_policy.populate(self, self.metadata.all_hosts())
        # on_up after populate allows things like DCA LBP to choose default local dc
        for host in filter(lambda h: h.is_up, self.metadata.all_hosts()):
            profile.load_balancing_policy.on_up(host)
        futures = set()
        for session in tuple(self.sessions):
            futures.update(session.update_created_pools())
        _, not_done = wait_futures(futures, pool_wait_timeout)
        if not_done:
            raise OperationTimedOut("Failed to create all new connection pools in the %ss timeout.")
def add_execution_profile ( self , name , profile , pool_wait_timeout = 5 ) : if not isinstance ( profile , ExecutionProfile ) : raise TypeError ( "profile must be an instance of ExecutionProfile" ) if self . _config_mode == _ConfigMode . LEGACY : raise ValueError ( "Cannot add execution profiles when legacy parameters are set explicitly." ) if name in self . profile_manager . profiles : raise ValueError ( "Profile {} already exists" . format ( name ) ) contact_points_but_no_lbp = ( self . _contact_points_explicit and not profile . _load_balancing_policy_explicit ) if contact_points_but_no_lbp : log . warning ( 'Tried to add an ExecutionProfile with name {name}. ' '{self} was explicitly configured with contact_points, but ' '{ep} was not explicitly configured with a ' 'load_balancing_policy. In the next major version, trying to ' 'add an ExecutionProfile without an explicitly configured LBP ' 'to a cluster with explicitly configured contact_points will ' 'raise an exception; please specify a load-balancing policy ' 'in the ExecutionProfile.' '' . format ( name = repr ( name ) , self = self , ep = profile ) ) self . profile_manager . profiles [ name ] = profile profile . load_balancing_policy . populate ( self , self . metadata . all_hosts ( ) ) for host in filter ( lambda h : h . is_up , self . metadata . all_hosts ( ) ) : profile . load_balancing_policy . on_up ( host ) futures = set ( ) for session in tuple ( self . sessions ) : futures . update ( session . update_created_pools ( ) ) _ , not_done = wait_futures ( futures , pool_wait_timeout ) if not_done : raise OperationTimedOut ( "Failed to create all new connection pools in the %ss timeout." )
Adds an :class:`.ExecutionProfile` to the cluster. This makes it available for use by ``name`` in :meth:`.Session.execute`
        and :meth:`.Session.execute_async`. This method will raise if the profile already exists.

        Normally profiles will be injected at cluster initialization via ``Cluster(execution_profiles)``. This method
        provides a way of adding them dynamically.

        Adding a new profile updates the connection pools according to the specified ``load_balancing_policy``. By default,
        this method will wait up to five seconds for the pool creation to complete, so the profile can be used immediately
        upon return. This behavior can be controlled using ``pool_wait_timeout`` (see
        `concurrent.futures.wait <https://docs.python.org/3/library/concurrent.futures.html#concurrent.futures.wait>`_
        for timeout semantics).