2626import sys
2727import time
2828from threading import Lock , RLock , Thread , Event
29- import Queue
29+
30+ import six
31+ from six .moves import range
32+ from six .moves import queue as Queue
33+
3034import weakref
3135from weakref import WeakValueDictionary
3236try :
@@ -696,7 +700,7 @@ def on_down(self, host, is_host_addition, expect_host_to_be_down=False):
696700
697701 host .set_down ()
698702
699- log .warn ("Host %s has been marked down" , host )
703+ log .warning ("Host %s has been marked down" , host )
700704
701705 self .load_balancing_policy .on_down (host )
702706 self .control_connection .on_down (host )
@@ -742,7 +746,7 @@ def future_completed(future):
742746 return
743747
744748 if not all (futures_results ):
745- log .warn ("Connection pool could not be created, not marking node %s up" , host )
749+ log .warning ("Connection pool could not be created, not marking node %s up" , host )
746750 return
747751
748752 self ._finalize_add (host )
@@ -867,7 +871,7 @@ def _prepare_all_queries(self, host):
867871 # prepare 10 statements at a time
868872 ks_statements = list (ks_statements )
869873 chunks = []
870- for i in xrange (0 , len (ks_statements ), 10 ):
874+ for i in range (0 , len (ks_statements ), 10 ):
871875 chunks .append (ks_statements [i :i + 10 ])
872876
873877 for ks_chunk in chunks :
@@ -882,9 +886,9 @@ def _prepare_all_queries(self, host):
882886
883887 log .debug ("Done preparing all known prepared statements against host %s" , host )
884888 except OperationTimedOut as timeout :
885- log .warn ("Timed out trying to prepare all statements on host %s: %s" , host , timeout )
889+ log .warning ("Timed out trying to prepare all statements on host %s: %s" , host , timeout )
886890 except (ConnectionException , socket .error ) as exc :
887- log .warn ("Error trying to prepare all statements on host %s: %r" , host , exc )
891+ log .warning ("Error trying to prepare all statements on host %s: %r" , host , exc )
888892 except Exception :
889893 log .exception ("Error trying to prepare all statements on host %s" , host )
890894 finally :
@@ -1088,7 +1092,7 @@ def _create_response_future(self, query, parameters, trace):
10881092
10891093 prepared_statement = None
10901094
1091- if isinstance (query , basestring ):
1095+ if isinstance (query , six . string_types ):
10921096 query = SimpleStatement (query )
10931097 elif isinstance (query , PreparedStatement ):
10941098 query = query .bind (parameters )
@@ -1235,8 +1239,8 @@ def run_add_or_renew_pool():
12351239 self .cluster .signal_connection_failure (host , conn_exc , is_host_addition )
12361240 return False
12371241 except Exception as conn_exc :
1238- log .warn ("Failed to create connection pool for new host %s: %s" ,
1239- host , conn_exc )
1242+ log .warning ("Failed to create connection pool for new host %s: %s" ,
1243+ host , conn_exc )
12401244 # the host itself will still be marked down, so we need to pass
12411245 # a special flag to make sure the reconnector is created
12421246 self .cluster .signal_connection_failure (
@@ -1456,11 +1460,11 @@ def _reconnect_internal(self):
14561460 return self ._try_connect (host )
14571461 except ConnectionException as exc :
14581462 errors [host .address ] = exc
1459- log .warn ("[control connection] Error connecting to %s:" , host , exc_info = True )
1463+ log .warning ("[control connection] Error connecting to %s:" , host , exc_info = True )
14601464 self ._cluster .signal_connection_failure (host , exc , is_host_addition = False )
14611465 except Exception as exc :
14621466 errors [host .address ] = exc
1463- log .warn ("[control connection] Error connecting to %s:" , host , exc_info = True )
1467+ log .warning ("[control connection] Error connecting to %s:" , host , exc_info = True )
14641468
14651469 raise NoHostAvailable ("Unable to connect to any servers" , errors )
14661470
@@ -1948,7 +1952,7 @@ def run(self):
19481952 def _log_if_failed (self , future ):
19491953 exc = future .exception ()
19501954 if exc :
1951- log .warn (
1955+ log .warning (
19521956 "An internally scheduled tasked failed with an unhandled exception:" ,
19531957 exc_info = exc )
19541958
@@ -2170,8 +2174,8 @@ def _set_result(self, response):
21702174 if self ._metrics is not None :
21712175 self ._metrics .on_other_error ()
21722176 # need to retry against a different host here
2173- log .warn ("Host %s is overloaded, retrying against a different "
2174- "host" , self ._current_host )
2177+ log .warning ("Host %s is overloaded, retrying against a different "
2178+ "host" , self ._current_host )
21752179 self ._retry (reuse_connection = False , consistency_level = None )
21762180 return
21772181 elif isinstance (response , IsBootstrappingErrorMessage ):
0 commit comments