|
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 |
|
29 | 30 | import logging |
30 | 31 | from warnings import warn |
31 | 32 | from random import random |
32 | | -import six |
33 | | -from six.moves import filter, range, queue as Queue |
| 33 | +import re |
| 34 | +import queue |
34 | 35 | import socket |
35 | 36 | import sys |
36 | 37 | import time |
|
79 | 80 | HostTargetingStatement) |
80 | 81 | from cassandra.marshal import int64_pack |
81 | 82 | from cassandra.timestamps import MonotonicTimestampGenerator |
82 | | -from cassandra.compat import Mapping |
83 | 83 | from cassandra.util import _resolve_contact_points_to_string_map, Version |
84 | 84 |
|
85 | 85 | from cassandra.datastax.insights.reporter import MonitorReporter |
|
111 | 111 | except ImportError: |
112 | 112 | from cassandra.util import WeakSet # NOQA |
113 | 113 |
|
114 | | -if six.PY3: |
115 | | - long = int |
116 | | - |
117 | 114 | def _is_eventlet_monkey_patched(): |
118 | 115 | if 'eventlet.patcher' not in sys.modules: |
119 | 116 | return False |
@@ -1158,7 +1155,7 @@ def __init__(self, |
1158 | 1155 | else: |
1159 | 1156 | self._contact_points_explicit = True |
1160 | 1157 |
|
1161 | | - if isinstance(contact_points, six.string_types): |
| 1158 | + if isinstance(contact_points, str): |
1162 | 1159 | raise TypeError("contact_points should not be a string, it should be a sequence (e.g. list) of strings") |
1163 | 1160 |
|
1164 | 1161 | if None in contact_points: |
@@ -1793,8 +1790,8 @@ def _new_session(self, keyspace): |
1793 | 1790 | return session |
1794 | 1791 |
|
1795 | 1792 | def _session_register_user_types(self, session): |
1796 | | - for keyspace, type_map in six.iteritems(self._user_types): |
1797 | | - for udt_name, klass in six.iteritems(type_map): |
| 1793 | + for keyspace, type_map in self._user_types.items(): |
| 1794 | + for udt_name, klass in type_map.items(): |
1798 | 1795 | session.user_type_registered(keyspace, udt_name, klass) |
1799 | 1796 |
|
1800 | 1797 | def _cleanup_failed_on_up_handling(self, host): |
@@ -2683,7 +2680,7 @@ def execute_async(self, query, parameters=None, trace=False, custom_payload=None |
2683 | 2680 | """ |
2684 | 2681 | custom_payload = custom_payload if custom_payload else {} |
2685 | 2682 | if execute_as: |
2686 | | - custom_payload[_proxy_execute_key] = six.b(execute_as) |
| 2683 | + custom_payload[_proxy_execute_key] = execute_as.encode() |
2687 | 2684 |
|
2688 | 2685 | future = self._create_response_future( |
2689 | 2686 | query, parameters, trace, custom_payload, timeout, |
@@ -2747,8 +2744,8 @@ def execute_graph_async(self, query, parameters=None, trace=False, execution_pro |
2747 | 2744 |
|
2748 | 2745 | custom_payload = execution_profile.graph_options.get_options_map() |
2749 | 2746 | if execute_as: |
2750 | | - custom_payload[_proxy_execute_key] = six.b(execute_as) |
2751 | | - custom_payload[_request_timeout_key] = int64_pack(long(execution_profile.request_timeout * 1000)) |
| 2747 | + custom_payload[_proxy_execute_key] = execute_as.encode() |
| 2748 | + custom_payload[_request_timeout_key] = int64_pack(int(execution_profile.request_timeout * 1000)) |
2752 | 2749 |
|
2753 | 2750 | future = self._create_response_future(query, parameters=None, trace=trace, custom_payload=custom_payload, |
2754 | 2751 | timeout=_NOT_SET, execution_profile=execution_profile) |
@@ -2885,7 +2882,7 @@ def _create_response_future(self, query, parameters, trace, custom_payload, |
2885 | 2882 |
|
2886 | 2883 | prepared_statement = None |
2887 | 2884 |
|
2888 | | - if isinstance(query, six.string_types): |
| 2885 | + if isinstance(query, str): |
2889 | 2886 | query = SimpleStatement(query) |
2890 | 2887 | elif isinstance(query, PreparedStatement): |
2891 | 2888 | query = query.bind(parameters) |
@@ -3353,10 +3350,6 @@ def user_type_registered(self, keyspace, user_type, klass): |
3353 | 3350 | 'User type %s does not exist in keyspace %s' % (user_type, keyspace)) |
3354 | 3351 |
|
3355 | 3352 | field_names = type_meta.field_names |
3356 | | - if six.PY2: |
3357 | | - # go from unicode to string to avoid decode errors from implicit |
3358 | | - # decode when formatting non-ascii values |
3359 | | - field_names = [fn.encode('utf-8') for fn in field_names] |
3360 | 3353 |
|
3361 | 3354 | def encode(val): |
3362 | 3355 | return '{ %s }' % ' , '.join('%s : %s' % ( |
@@ -4035,7 +4028,7 @@ def _get_schema_mismatches(self, peers_result, local_result, local_address): |
4035 | 4028 | log.debug("[control connection] Schemas match") |
4036 | 4029 | return None |
4037 | 4030 |
|
4038 | | - return dict((version, list(nodes)) for version, nodes in six.iteritems(versions)) |
| 4031 | + return dict((version, list(nodes)) for version, nodes in versions.items()) |
4039 | 4032 |
|
4040 | 4033 | def _get_peers_query(self, peers_query_type, connection=None): |
4041 | 4034 | """ |
@@ -4155,7 +4148,7 @@ class _Scheduler(Thread): |
4155 | 4148 | is_shutdown = False |
4156 | 4149 |
|
4157 | 4150 | def __init__(self, executor): |
4158 | | - self._queue = Queue.PriorityQueue() |
| 4151 | + self._queue = queue.PriorityQueue() |
4159 | 4152 | self._scheduled_tasks = set() |
4160 | 4153 | self._count = count() |
4161 | 4154 | self._executor = executor |
@@ -4213,7 +4206,7 @@ def run(self): |
4213 | 4206 | else: |
4214 | 4207 | self._queue.put_nowait((run_at, i, task)) |
4215 | 4208 | break |
4216 | | - except Queue.Empty: |
| 4209 | + except queue.Empty: |
4217 | 4210 | pass |
4218 | 4211 |
|
4219 | 4212 | time.sleep(0.1) |
|
0 commit comments