fixing references to removed vars
This commit is contained in:
		| @@ -22,7 +22,7 @@ Host = namedtuple('Host', ['name', 'port']) | |||||||
| _max_connections = 10 | _max_connections = 10 | ||||||
| _connection_pool = None | _connection_pool = None | ||||||
|  |  | ||||||
| def setup(hosts, username=None, password=None, max_connections=10, default_keyspace=None, lazy=True): | def setup(hosts, username=None, password=None, max_connections=10, default_keyspace=None): | ||||||
|     """ |     """ | ||||||
|     Records the hosts and connects to one of them |     Records the hosts and connects to one of them | ||||||
|  |  | ||||||
| @@ -36,6 +36,7 @@ def setup(hosts, username=None, password=None, max_connections=10, default_keysp | |||||||
|         from cqlengine import models |         from cqlengine import models | ||||||
|         models.DEFAULT_KEYSPACE = default_keyspace |         models.DEFAULT_KEYSPACE = default_keyspace | ||||||
|  |  | ||||||
|  |     _hosts = [] | ||||||
|     for host in hosts: |     for host in hosts: | ||||||
|         host = host.strip() |         host = host.strip() | ||||||
|         host = host.split(':') |         host = host.split(':') | ||||||
| @@ -51,10 +52,6 @@ def setup(hosts, username=None, password=None, max_connections=10, default_keysp | |||||||
|  |  | ||||||
|     _connection_pool = ConnectionPool(_hosts) |     _connection_pool = ConnectionPool(_hosts) | ||||||
|  |  | ||||||
|     if not lazy: |  | ||||||
|         con = _connection_pool.get() |  | ||||||
|         _connection_pool.put(con) |  | ||||||
|  |  | ||||||
|  |  | ||||||
| class ConnectionPool(object): | class ConnectionPool(object): | ||||||
|     """Handles pooling of database connections.""" |     """Handles pooling of database connections.""" | ||||||
| @@ -101,15 +98,11 @@ class ConnectionPool(object): | |||||||
|         :param conn: The connection to be released |         :param conn: The connection to be released | ||||||
|         :type conn: connection |         :type conn: connection | ||||||
|         """ |         """ | ||||||
|         try: |  | ||||||
|         if self._queue.full(): |         if self._queue.full(): | ||||||
|             conn.close() |             conn.close() | ||||||
|         else: |         else: | ||||||
|             self._queue.put(conn) |             self._queue.put(conn) | ||||||
|         except: |  | ||||||
|             if not self._queue: |  | ||||||
|                 self._queue = |  | ||||||
|             self._queue.put(conn) |  | ||||||
|  |  | ||||||
|     def _create_connection(self): |     def _create_connection(self): | ||||||
|         """ |         """ | ||||||
| @@ -117,11 +110,7 @@ class ConnectionPool(object): | |||||||
|  |  | ||||||
|         should only return a valid connection that it's actually connected to |         should only return a valid connection that it's actually connected to | ||||||
|         """ |         """ | ||||||
|         global _hosts |         if not self._hosts: | ||||||
|         global _username |  | ||||||
|         global _password |  | ||||||
|  |  | ||||||
|         if not _hosts: |  | ||||||
|             raise CQLConnectionError("At least one host required") |             raise CQLConnectionError("At least one host required") | ||||||
|  |  | ||||||
|         host = _hosts[_host_idx] |         host = _hosts[_host_idx] | ||||||
|   | |||||||
| @@ -6,7 +6,7 @@ class BaseCassEngTestCase(TestCase): | |||||||
|     @classmethod |     @classmethod | ||||||
|     def setUpClass(cls): |     def setUpClass(cls): | ||||||
|         super(BaseCassEngTestCase, cls).setUpClass() |         super(BaseCassEngTestCase, cls).setUpClass() | ||||||
|         if not connection._hosts: |         if not connection._connection_pool: | ||||||
|             connection.setup(['localhost:9160'], default_keyspace='cqlengine_test') |             connection.setup(['localhost:9160'], default_keyspace='cqlengine_test') | ||||||
|  |  | ||||||
|     def assertHasAttr(self, obj, attr): |     def assertHasAttr(self, obj, attr): | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Jon Haddad
					Jon Haddad