diff --git a/taskflow/utils/lock_utils.py b/taskflow/utils/lock_utils.py index 2aaea930..954e606b 100644 --- a/taskflow/utils/lock_utils.py +++ b/taskflow/utils/lock_utils.py @@ -63,7 +63,7 @@ def locked(*args, **kwargs): def decorator(f): attr_name = kwargs.get('lock', '_lock') - @misc.wraps(f) + @six.wraps(f) def wrapper(*args, **kwargs): lock = getattr(args[0], attr_name) if isinstance(lock, (tuple, list)): diff --git a/taskflow/utils/misc.py b/taskflow/utils/misc.py index 607bbe2a..eea56d6d 100644 --- a/taskflow/utils/misc.py +++ b/taskflow/utils/misc.py @@ -20,7 +20,6 @@ import contextlib import copy import datetime import errno -import functools import inspect import keyword import logging @@ -233,21 +232,6 @@ def wallclock(): return time.time() -def wraps(fn): - """Wraps a method and ensures the __wrapped__ attribute is set. - - NOTE(harlowja): This will not be needed in python 3.2 or greater which - already has this built-in to its functools.wraps method. - """ - - def wrapper(f): - f = functools.wraps(fn)(f) - f.__wrapped__ = getattr(fn, '__wrapped__', fn) - return f - - return wrapper - - def millis_to_datetime(milliseconds): """Converts number of milliseconds (from epoch) into a datetime object.""" return datetime.datetime.fromtimestamp(float(milliseconds) / 1000) diff --git a/taskflow/utils/threading_utils.py b/taskflow/utils/threading_utils.py index c669619a..2af17023 100644 --- a/taskflow/utils/threading_utils.py +++ b/taskflow/utils/threading_utils.py @@ -17,13 +17,12 @@ import multiprocessing import threading -import six +from six.moves import _thread -if six.PY2: - from thread import get_ident # noqa -else: - # In python3+ the get_ident call moved (whhhy??) - from threading import get_ident # noqa + +def get_ident(): + """Return the 'thread identifier' of the current thread.""" + return _thread.get_ident() def get_optimal_thread_count():