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:
parent
689ac0d47e
commit
57678fc04c
|
@ -15,13 +15,11 @@
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import functools
|
import functools
|
||||||
|
import queue
|
||||||
import threading
|
import threading
|
||||||
|
|
||||||
from concurrent import futures as _futures
|
from concurrent import futures as _futures
|
||||||
from concurrent.futures import process as _process
|
from concurrent.futures import process as _process
|
||||||
import six
|
|
||||||
|
|
||||||
from six.moves import queue as compat_queue
|
|
||||||
|
|
||||||
from futurist import _green
|
from futurist import _green
|
||||||
from futurist import _thread
|
from futurist import _thread
|
||||||
|
@ -133,7 +131,7 @@ class ThreadPoolExecutor(_futures.Executor):
|
||||||
if max_workers <= 0:
|
if max_workers <= 0:
|
||||||
raise ValueError("Max workers must be greater than zero")
|
raise ValueError("Max workers must be greater than zero")
|
||||||
self._max_workers = max_workers
|
self._max_workers = max_workers
|
||||||
self._work_queue = compat_queue.Queue()
|
self._work_queue = queue.Queue()
|
||||||
self._shutdown_lock = threading.RLock()
|
self._shutdown_lock = threading.RLock()
|
||||||
self._shutdown = False
|
self._shutdown = False
|
||||||
self._workers = []
|
self._workers = []
|
||||||
|
@ -171,7 +169,7 @@ class ThreadPoolExecutor(_futures.Executor):
|
||||||
w.stop()
|
w.stop()
|
||||||
if wait:
|
if wait:
|
||||||
for w in self._workers:
|
for w in self._workers:
|
||||||
_thread.join_thread(w)
|
w.join()
|
||||||
|
|
||||||
def _submit(self, fn, *args, **kwargs):
|
def _submit(self, fn, *args, **kwargs):
|
||||||
f = Future()
|
f = Future()
|
||||||
|
@ -254,7 +252,7 @@ class SynchronousExecutor(_futures.Executor):
|
||||||
if green and not _utils.EVENTLET_AVAILABLE:
|
if green and not _utils.EVENTLET_AVAILABLE:
|
||||||
raise RuntimeError('Eventlet is needed to use a green'
|
raise RuntimeError('Eventlet is needed to use a green'
|
||||||
' synchronous executor')
|
' synchronous executor')
|
||||||
if not six.callable(run_work_func):
|
if not callable(run_work_func):
|
||||||
raise ValueError("Run work parameter expected to be callable")
|
raise ValueError("Run work parameter expected to be callable")
|
||||||
self._run_work_func = run_work_func
|
self._run_work_func = run_work_func
|
||||||
self._shutoff = False
|
self._shutoff = False
|
||||||
|
|
|
@ -13,13 +13,10 @@
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import atexit
|
import atexit
|
||||||
import sys
|
import queue
|
||||||
import threading
|
import threading
|
||||||
import weakref
|
import weakref
|
||||||
|
|
||||||
import six
|
|
||||||
from six.moves import queue as compat_queue
|
|
||||||
|
|
||||||
|
|
||||||
class Threading(object):
|
class Threading(object):
|
||||||
|
|
||||||
|
@ -42,16 +39,6 @@ class Threading(object):
|
||||||
|
|
||||||
_to_be_cleaned = weakref.WeakKeyDictionary()
|
_to_be_cleaned = weakref.WeakKeyDictionary()
|
||||||
_dying = False
|
_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()
|
_TOMBSTONE = object()
|
||||||
|
|
||||||
|
|
||||||
|
@ -97,7 +84,7 @@ class ThreadWorker(threading.Thread):
|
||||||
while work is None:
|
while work is None:
|
||||||
try:
|
try:
|
||||||
work = self.work_queue.get(True, self.MAX_IDLE_FOR)
|
work = self.work_queue.get(True, self.MAX_IDLE_FOR)
|
||||||
except compat_queue.Empty:
|
except queue.Empty:
|
||||||
if self._is_dying():
|
if self._is_dying():
|
||||||
work = _TOMBSTONE
|
work = _TOMBSTONE
|
||||||
self.idle = False
|
self.idle = False
|
||||||
|
@ -138,7 +125,7 @@ def _clean_up():
|
||||||
while threads_to_wait_for:
|
while threads_to_wait_for:
|
||||||
worker = threads_to_wait_for.pop()
|
worker = threads_to_wait_for.pop()
|
||||||
try:
|
try:
|
||||||
join_thread(worker)
|
worker.join()
|
||||||
finally:
|
finally:
|
||||||
del worker
|
del worker
|
||||||
|
|
||||||
|
|
|
@ -22,8 +22,6 @@ import threading
|
||||||
from time import monotonic
|
from time import monotonic
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
import six
|
|
||||||
|
|
||||||
now = monotonic
|
now = monotonic
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -60,10 +58,7 @@ class WorkItem(object):
|
||||||
def fail(self, exc_info=None):
|
def fail(self, exc_info=None):
|
||||||
exc_type, exc_value, exc_tb = exc_info or sys.exc_info()
|
exc_type, exc_value, exc_tb = exc_info or sys.exc_info()
|
||||||
try:
|
try:
|
||||||
if six.PY2:
|
self.future.set_exception(exc_value)
|
||||||
self.future.set_exception_info(exc_value, exc_tb)
|
|
||||||
else:
|
|
||||||
self.future.set_exception(exc_value)
|
|
||||||
finally:
|
finally:
|
||||||
if exc_info is None:
|
if exc_info is None:
|
||||||
del exc_type, exc_value, exc_tb
|
del exc_type, exc_value, exc_tb
|
||||||
|
|
|
@ -29,7 +29,6 @@ try:
|
||||||
import prettytable
|
import prettytable
|
||||||
except ImportError:
|
except ImportError:
|
||||||
prettytable = None
|
prettytable = None
|
||||||
import six
|
|
||||||
|
|
||||||
import futurist
|
import futurist
|
||||||
from futurist import _utils as utils
|
from futurist import _utils as utils
|
||||||
|
@ -176,7 +175,7 @@ def periodic(spacing, run_immediately=False, enabled=True):
|
||||||
f._periodic_spacing = spacing
|
f._periodic_spacing = spacing
|
||||||
f._periodic_run_immediately = run_immediately
|
f._periodic_run_immediately = run_immediately
|
||||||
|
|
||||||
@six.wraps(f)
|
@functools.wraps(f)
|
||||||
def decorator(*args, **kwargs):
|
def decorator(*args, **kwargs):
|
||||||
return f(*args, **kwargs)
|
return f(*args, **kwargs)
|
||||||
|
|
||||||
|
@ -198,7 +197,7 @@ def _add_jitter(max_percent_jitter):
|
||||||
def wrapper(func):
|
def wrapper(func):
|
||||||
rnd = random.SystemRandom()
|
rnd = random.SystemRandom()
|
||||||
|
|
||||||
@six.wraps(func)
|
@functools.wraps(func)
|
||||||
def decorator(cb, started_at, finished_at, metrics):
|
def decorator(cb, started_at, finished_at, metrics):
|
||||||
next_run = func(cb, started_at, finished_at, metrics)
|
next_run = func(cb, started_at, finished_at, metrics)
|
||||||
how_often = cb._periodic_spacing
|
how_often = cb._periodic_spacing
|
||||||
|
@ -485,7 +484,7 @@ class PeriodicWorker(object):
|
||||||
for (name, member) in inspect.getmembers(obj):
|
for (name, member) in inspect.getmembers(obj):
|
||||||
if name.startswith("_") and exclude_hidden:
|
if name.startswith("_") and exclude_hidden:
|
||||||
continue
|
continue
|
||||||
if six.callable(member):
|
if callable(member):
|
||||||
missing_attrs = _check_attrs(member)
|
missing_attrs = _check_attrs(member)
|
||||||
if not missing_attrs:
|
if not missing_attrs:
|
||||||
callables.append((member, args, kwargs))
|
callables.append((member, args, kwargs))
|
||||||
|
@ -557,7 +556,7 @@ class PeriodicWorker(object):
|
||||||
exceptions on being called)
|
exceptions on being called)
|
||||||
:type on_failure: callable
|
: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"
|
raise ValueError("On failure callback %r must be"
|
||||||
" callable" % on_failure)
|
" callable" % on_failure)
|
||||||
self._tombstone = event_cls()
|
self._tombstone = event_cls()
|
||||||
|
@ -568,7 +567,7 @@ class PeriodicWorker(object):
|
||||||
self._watchers = []
|
self._watchers = []
|
||||||
self._works = []
|
self._works = []
|
||||||
for (cb, args, kwargs) in callables:
|
for (cb, args, kwargs) in callables:
|
||||||
if not six.callable(cb):
|
if not callable(cb):
|
||||||
raise ValueError("Periodic callback %r must be callable" % cb)
|
raise ValueError("Periodic callback %r must be callable" % cb)
|
||||||
missing_attrs = _check_attrs(cb)
|
missing_attrs = _check_attrs(cb)
|
||||||
if missing_attrs:
|
if missing_attrs:
|
||||||
|
@ -828,7 +827,7 @@ class PeriodicWorker(object):
|
||||||
with the :py:func:`.periodic` decorator
|
with the :py:func:`.periodic` decorator
|
||||||
:type cb: callable
|
:type cb: callable
|
||||||
"""
|
"""
|
||||||
if not six.callable(cb):
|
if not callable(cb):
|
||||||
raise ValueError("Periodic callback %r must be callable" % cb)
|
raise ValueError("Periodic callback %r must be callable" % cb)
|
||||||
missing_attrs = _check_attrs(cb)
|
missing_attrs = _check_attrs(cb)
|
||||||
if missing_attrs:
|
if missing_attrs:
|
||||||
|
@ -919,7 +918,7 @@ class PeriodicWorker(object):
|
||||||
self._tombstone.clear()
|
self._tombstone.clear()
|
||||||
self._dead.clear()
|
self._dead.clear()
|
||||||
for cb_metrics, _watcher in self._watchers:
|
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
|
# NOTE(harlowja): mutate the original dictionaries keys
|
||||||
# so that the watcher (which references the same dictionary
|
# so that the watcher (which references the same dictionary
|
||||||
# keys) is able to see those changes.
|
# keys) is able to see those changes.
|
||||||
|
|
|
@ -21,10 +21,10 @@ except ImportError:
|
||||||
|
|
||||||
import collections
|
import collections
|
||||||
import contextlib
|
import contextlib
|
||||||
|
import functools
|
||||||
|
|
||||||
from concurrent import futures
|
from concurrent import futures
|
||||||
from concurrent.futures import _base
|
from concurrent.futures import _base
|
||||||
import six
|
|
||||||
|
|
||||||
import futurist
|
import futurist
|
||||||
from futurist import _utils
|
from futurist import _utils
|
||||||
|
@ -60,7 +60,7 @@ def _acquire_and_release_futures(fs):
|
||||||
def _ensure_eventlet(func):
|
def _ensure_eventlet(func):
|
||||||
"""Decorator that verifies we have the needed eventlet components."""
|
"""Decorator that verifies we have the needed eventlet components."""
|
||||||
|
|
||||||
@six.wraps(func)
|
@functools.wraps(func)
|
||||||
def wrapper(*args, **kwargs):
|
def wrapper(*args, **kwargs):
|
||||||
if not _utils.EVENTLET_AVAILABLE or greenthreading is None:
|
if not _utils.EVENTLET_AVAILABLE or greenthreading is None:
|
||||||
raise RuntimeError('Eventlet is needed to wait on green futures')
|
raise RuntimeError('Eventlet is needed to wait on green futures')
|
||||||
|
|
|
@ -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
|
pbr!=2.1.0,>=2.0.0 # Apache-2.0
|
||||||
six>=1.10.0 # MIT
|
|
||||||
|
|
Loading…
Reference in New Issue