Remove six

We don't need this dependency anymore

Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Change-Id: I93d0c05b1f63c86040b52cdaea99ffb42bad3f07
This commit is contained in:
Stephen Finucane 2022-04-05 16:56:32 +01:00
parent 689ac0d47e
commit 57678fc04c
6 changed files with 17 additions and 43 deletions

View File

@ -15,13 +15,11 @@
# under the License.
import functools
import queue
import threading
from concurrent import futures as _futures
from concurrent.futures import process as _process
import six
from six.moves import queue as compat_queue
from futurist import _green
from futurist import _thread
@ -133,7 +131,7 @@ class ThreadPoolExecutor(_futures.Executor):
if max_workers <= 0:
raise ValueError("Max workers must be greater than zero")
self._max_workers = max_workers
self._work_queue = compat_queue.Queue()
self._work_queue = queue.Queue()
self._shutdown_lock = threading.RLock()
self._shutdown = False
self._workers = []
@ -171,7 +169,7 @@ class ThreadPoolExecutor(_futures.Executor):
w.stop()
if wait:
for w in self._workers:
_thread.join_thread(w)
w.join()
def _submit(self, fn, *args, **kwargs):
f = Future()
@ -254,7 +252,7 @@ class SynchronousExecutor(_futures.Executor):
if green and not _utils.EVENTLET_AVAILABLE:
raise RuntimeError('Eventlet is needed to use a green'
' synchronous executor')
if not six.callable(run_work_func):
if not callable(run_work_func):
raise ValueError("Run work parameter expected to be callable")
self._run_work_func = run_work_func
self._shutoff = False

View File

@ -13,13 +13,10 @@
# under the License.
import atexit
import sys
import queue
import threading
import weakref
import six
from six.moves import queue as compat_queue
class Threading(object):
@ -42,16 +39,6 @@ class Threading(object):
_to_be_cleaned = weakref.WeakKeyDictionary()
_dying = False
if six.PY2:
# This ensures joining responds to keyboard interrupts.
join_thread = lambda thread: thread.join(sys.maxint)
else:
# Not needed on py3 or newer...
join_thread = lambda thread: thread.join()
_TOMBSTONE = object()
@ -97,7 +84,7 @@ class ThreadWorker(threading.Thread):
while work is None:
try:
work = self.work_queue.get(True, self.MAX_IDLE_FOR)
except compat_queue.Empty:
except queue.Empty:
if self._is_dying():
work = _TOMBSTONE
self.idle = False
@ -138,7 +125,7 @@ def _clean_up():
while threads_to_wait_for:
worker = threads_to_wait_for.pop()
try:
join_thread(worker)
worker.join()
finally:
del worker

View File

@ -22,8 +22,6 @@ import threading
from time import monotonic
import traceback
import six
now = monotonic
try:
@ -60,10 +58,7 @@ class WorkItem(object):
def fail(self, exc_info=None):
exc_type, exc_value, exc_tb = exc_info or sys.exc_info()
try:
if six.PY2:
self.future.set_exception_info(exc_value, exc_tb)
else:
self.future.set_exception(exc_value)
self.future.set_exception(exc_value)
finally:
if exc_info is None:
del exc_type, exc_value, exc_tb

View File

@ -29,7 +29,6 @@ try:
import prettytable
except ImportError:
prettytable = None
import six
import futurist
from futurist import _utils as utils
@ -176,7 +175,7 @@ def periodic(spacing, run_immediately=False, enabled=True):
f._periodic_spacing = spacing
f._periodic_run_immediately = run_immediately
@six.wraps(f)
@functools.wraps(f)
def decorator(*args, **kwargs):
return f(*args, **kwargs)
@ -198,7 +197,7 @@ def _add_jitter(max_percent_jitter):
def wrapper(func):
rnd = random.SystemRandom()
@six.wraps(func)
@functools.wraps(func)
def decorator(cb, started_at, finished_at, metrics):
next_run = func(cb, started_at, finished_at, metrics)
how_often = cb._periodic_spacing
@ -485,7 +484,7 @@ class PeriodicWorker(object):
for (name, member) in inspect.getmembers(obj):
if name.startswith("_") and exclude_hidden:
continue
if six.callable(member):
if callable(member):
missing_attrs = _check_attrs(member)
if not missing_attrs:
callables.append((member, args, kwargs))
@ -557,7 +556,7 @@ class PeriodicWorker(object):
exceptions on being called)
:type on_failure: callable
"""
if on_failure is not None and not six.callable(on_failure):
if on_failure is not None and not callable(on_failure):
raise ValueError("On failure callback %r must be"
" callable" % on_failure)
self._tombstone = event_cls()
@ -568,7 +567,7 @@ class PeriodicWorker(object):
self._watchers = []
self._works = []
for (cb, args, kwargs) in callables:
if not six.callable(cb):
if not callable(cb):
raise ValueError("Periodic callback %r must be callable" % cb)
missing_attrs = _check_attrs(cb)
if missing_attrs:
@ -828,7 +827,7 @@ class PeriodicWorker(object):
with the :py:func:`.periodic` decorator
:type cb: callable
"""
if not six.callable(cb):
if not callable(cb):
raise ValueError("Periodic callback %r must be callable" % cb)
missing_attrs = _check_attrs(cb)
if missing_attrs:
@ -919,7 +918,7 @@ class PeriodicWorker(object):
self._tombstone.clear()
self._dead.clear()
for cb_metrics, _watcher in self._watchers:
for k in list(six.iterkeys(cb_metrics)):
for k in list(cb_metrics):
# NOTE(harlowja): mutate the original dictionaries keys
# so that the watcher (which references the same dictionary
# keys) is able to see those changes.

View File

@ -21,10 +21,10 @@ except ImportError:
import collections
import contextlib
import functools
from concurrent import futures
from concurrent.futures import _base
import six
import futurist
from futurist import _utils
@ -60,7 +60,7 @@ def _acquire_and_release_futures(fs):
def _ensure_eventlet(func):
"""Decorator that verifies we have the needed eventlet components."""
@six.wraps(func)
@functools.wraps(func)
def wrapper(*args, **kwargs):
if not _utils.EVENTLET_AVAILABLE or greenthreading is None:
raise RuntimeError('Eventlet is needed to wait on green futures')

View File

@ -1,6 +1 @@
# The order of packages is significant, because pip processes them in the order
# of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later.
pbr!=2.1.0,>=2.0.0 # Apache-2.0
six>=1.10.0 # MIT