Prepare the given query on all hosts, excluding ``excluded_host``. Intended for internal use only.
(self, query, excluded_host, keyspace=None)
| 3205 | return prepared_statement |
| 3206 | |
| 3207 | def prepare_on_all_hosts(self, query, excluded_host, keyspace=None): |
| 3208 | """ |
| 3209 | Prepare the given query on all hosts, excluding ``excluded_host``. |
| 3210 | Intended for internal use only. |
| 3211 | """ |
| 3212 | futures = [] |
| 3213 | for host in tuple(self._pools.keys()): |
| 3214 | if host != excluded_host and host.is_up: |
| 3215 | future = ResponseFuture(self, PrepareMessage(query=query, keyspace=keyspace), |
| 3216 | None, self.default_timeout) |
| 3217 | |
| 3218 | # we don't care about errors preparing against specific hosts, |
| 3219 | # since we can always prepare them as needed when the prepared |
| 3220 | # statement is used. Just log errors and continue on. |
| 3221 | try: |
| 3222 | request_id = future._query(host) |
| 3223 | except Exception: |
| 3224 | log.exception("Error preparing query for host %s:", host) |
| 3225 | continue |
| 3226 | |
| 3227 | if request_id is None: |
| 3228 | # the error has already been logged by ResponseFuture |
| 3229 | log.debug("Failed to prepare query for host %s: %r", |
| 3230 | host, future._errors.get(host)) |
| 3231 | continue |
| 3232 | |
| 3233 | futures.append((host, future)) |
| 3234 | |
| 3235 | for host, future in futures: |
| 3236 | try: |
| 3237 | future.result() |
| 3238 | except Exception: |
| 3239 | log.exception("Error preparing query for host %s:", host) |
| 3240 | |
| 3241 | def shutdown(self): |
| 3242 | """ |
no test coverage detected