|
21 | 21 | import atexit |
22 | 22 | from binascii import hexlify |
23 | 23 | from collections import defaultdict |
| 24 | +from collections.abc import Mapping |
24 | 25 | from concurrent.futures import ThreadPoolExecutor, FIRST_COMPLETED, wait as wait_futures |
25 | 26 | from copy import copy |
26 | 27 | from functools import partial, wraps |
|
30 | 31 | from warnings import warn |
31 | 32 | from random import random |
32 | 33 | import re |
33 | | -import six |
34 | | -from six.moves import filter, range, queue as Queue |
| 34 | +import queue |
35 | 35 | import socket |
36 | 36 | import sys |
37 | 37 | import time |
|
82 | 82 | from cassandra.marshal import int64_pack |
83 | 83 | from cassandra.tablets import Tablet, Tablets |
84 | 84 | from cassandra.timestamps import MonotonicTimestampGenerator |
85 | | -from cassandra.compat import Mapping |
86 | 85 | from cassandra.util import _resolve_contact_points_to_string_map, Version |
87 | 86 |
|
88 | 87 | from cassandra.datastax.insights.reporter import MonitorReporter |
|
113 | 112 | except ImportError: |
114 | 113 | from cassandra.util import WeakSet # NOQA |
115 | 114 |
|
116 | | -if six.PY3: |
117 | | - long = int |
118 | | - |
119 | 115 | def _is_eventlet_monkey_patched(): |
120 | 116 | if 'eventlet.patcher' not in sys.modules: |
121 | 117 | return False |
@@ -1219,7 +1215,7 @@ def __init__(self, |
1219 | 1215 | else: |
1220 | 1216 | self._contact_points_explicit = True |
1221 | 1217 |
|
1222 | | - if isinstance(contact_points, six.string_types): |
| 1218 | + if isinstance(contact_points, str): |
1223 | 1219 | raise TypeError("contact_points should not be a string, it should be a sequence (e.g. list) of strings") |
1224 | 1220 |
|
1225 | 1221 | if None in contact_points: |
@@ -1882,8 +1878,8 @@ def _new_session(self, keyspace): |
1882 | 1878 | return session |
1883 | 1879 |
|
1884 | 1880 | def _session_register_user_types(self, session): |
1885 | | - for keyspace, type_map in six.iteritems(self._user_types): |
1886 | | - for udt_name, klass in six.iteritems(type_map): |
| 1881 | + for keyspace, type_map in self._user_types.items(): |
| 1882 | + for udt_name, klass in type_map.items(): |
1887 | 1883 | session.user_type_registered(keyspace, udt_name, klass) |
1888 | 1884 |
|
1889 | 1885 | def _cleanup_failed_on_up_handling(self, host): |
@@ -2767,7 +2763,7 @@ def execute_async(self, query, parameters=None, trace=False, custom_payload=None |
2767 | 2763 | """ |
2768 | 2764 | custom_payload = custom_payload if custom_payload else {} |
2769 | 2765 | if execute_as: |
2770 | | - custom_payload[_proxy_execute_key] = six.b(execute_as) |
| 2766 | + custom_payload[_proxy_execute_key] = execute_as.encode() |
2771 | 2767 |
|
2772 | 2768 | future = self._create_response_future( |
2773 | 2769 | query, parameters, trace, custom_payload, timeout, |
@@ -2831,8 +2827,8 @@ def execute_graph_async(self, query, parameters=None, trace=False, execution_pro |
2831 | 2827 |
|
2832 | 2828 | custom_payload = execution_profile.graph_options.get_options_map() |
2833 | 2829 | if execute_as: |
2834 | | - custom_payload[_proxy_execute_key] = six.b(execute_as) |
2835 | | - custom_payload[_request_timeout_key] = int64_pack(long(execution_profile.request_timeout * 1000)) |
| 2830 | + custom_payload[_proxy_execute_key] = execute_as.encode() |
| 2831 | + custom_payload[_request_timeout_key] = int64_pack(int(execution_profile.request_timeout * 1000)) |
2836 | 2832 |
|
2837 | 2833 | future = self._create_response_future(query, parameters=None, trace=trace, custom_payload=custom_payload, |
2838 | 2834 | timeout=_NOT_SET, execution_profile=execution_profile) |
@@ -2969,7 +2965,7 @@ def _create_response_future(self, query, parameters, trace, custom_payload, |
2969 | 2965 |
|
2970 | 2966 | prepared_statement = None |
2971 | 2967 |
|
2972 | | - if isinstance(query, six.string_types): |
| 2968 | + if isinstance(query, str): |
2973 | 2969 | query = SimpleStatement(query) |
2974 | 2970 | elif isinstance(query, PreparedStatement): |
2975 | 2971 | query = query.bind(parameters) |
@@ -3437,10 +3433,6 @@ def user_type_registered(self, keyspace, user_type, klass): |
3437 | 3433 | 'User type %s does not exist in keyspace %s' % (user_type, keyspace)) |
3438 | 3434 |
|
3439 | 3435 | field_names = type_meta.field_names |
3440 | | - if six.PY2: |
3441 | | - # go from unicode to string to avoid decode errors from implicit |
3442 | | - # decode when formatting non-ascii values |
3443 | | - field_names = [fn.encode('utf-8') for fn in field_names] |
3444 | 3436 |
|
3445 | 3437 | def encode(val): |
3446 | 3438 | return '{ %s }' % ' , '.join('%s : %s' % ( |
@@ -4208,7 +4200,7 @@ def _get_schema_mismatches(self, peers_result, local_result, local_address): |
4208 | 4200 | log.debug("[control connection] Schemas match") |
4209 | 4201 | return None |
4210 | 4202 |
|
4211 | | - return dict((version, list(nodes)) for version, nodes in six.iteritems(versions)) |
| 4203 | + return dict((version, list(nodes)) for version, nodes in versions.items()) |
4212 | 4204 |
|
4213 | 4205 | def _get_peers_query(self, peers_query_type, connection=None): |
4214 | 4206 | """ |
@@ -4327,7 +4319,7 @@ class _Scheduler(Thread): |
4327 | 4319 | is_shutdown = False |
4328 | 4320 |
|
4329 | 4321 | def __init__(self, executor): |
4330 | | - self._queue = Queue.PriorityQueue() |
| 4322 | + self._queue = queue.PriorityQueue() |
4331 | 4323 | self._scheduled_tasks = set() |
4332 | 4324 | self._count = count() |
4333 | 4325 | self._executor = executor |
@@ -4385,7 +4377,7 @@ def run(self): |
4385 | 4377 | else: |
4386 | 4378 | self._queue.put_nowait((run_at, i, task)) |
4387 | 4379 | break |
4388 | | - except Queue.Empty: |
| 4380 | + except queue.Empty: |
4389 | 4381 | pass |
4390 | 4382 |
|
4391 | 4383 | time.sleep(0.1) |
|
0 commit comments