| 1506 | raise ProtocolError(msg % (self.endpoint, auth_response)) |
| 1507 | |
| 1508 | def set_keyspace_blocking(self, keyspace): |
| 1509 | if not keyspace or keyspace == self.keyspace: |
| 1510 | return |
| 1511 | |
| 1512 | query = QueryMessage(query='USE "%s"' % (keyspace,), |
| 1513 | consistency_level=ConsistencyLevel.ONE) |
| 1514 | try: |
| 1515 | result = self.wait_for_response(query) |
| 1516 | except InvalidRequestException as ire: |
| 1517 | # the keyspace probably doesn't exist |
| 1518 | raise ire.to_exception() |
| 1519 | except Exception as exc: |
| 1520 | conn_exc = ConnectionException( |
| 1521 | "Problem while setting keyspace: %r" % (exc,), self.endpoint) |
| 1522 | self.defunct(conn_exc) |
| 1523 | raise conn_exc |
| 1524 | |
| 1525 | if isinstance(result, ResultMessage): |
| 1526 | self.keyspace = keyspace |
| 1527 | else: |
| 1528 | conn_exc = ConnectionException( |
| 1529 | "Problem while setting keyspace: %r" % (result,), self.endpoint) |
| 1530 | self.defunct(conn_exc) |
| 1531 | raise conn_exc |
| 1532 | |
| 1533 | def set_keyspace_async(self, keyspace, callback): |
| 1534 | """ |