# Copyright 2013-2014 DataStax, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """ Connection pooling and host management. """ import logging import re import socket import time from threading import RLock, Condition import weakref try: from weakref import WeakSet except ImportError: from cassandra.util import WeakSet # NOQA from cassandra import AuthenticationFailed from cassandra.connection import MAX_STREAM_PER_CONNECTION, ConnectionException log = logging.getLogger(__name__) class NoConnectionsAvailable(Exception): """ All existing connections to a given host are busy, or there are no open connections. """ pass # example matches: # 1.0.0 # 1.0.0-beta1 # 2.0-SNAPSHOT version_re = re.compile(r"(?P\d+)\.(?P\d+)(?:\.(?P\d+))?(?:-(?P