diff --git a/oslo_utils/timeutils.py b/oslo_utils/timeutils.py index 17495e49..47859a75 100644 --- a/oslo_utils/timeutils.py +++ b/oslo_utils/timeutils.py @@ -23,6 +23,7 @@ import time from debtcollector import removals import iso8601 +from monotonic import monotonic as now # noqa from pytz import timezone import six @@ -35,19 +36,6 @@ PERFECT_TIME_FORMAT = _ISO8601_TIME_FORMAT_SUBSECOND _MAX_DATETIME_SEC = 59 -# Use monotonic time in stopwatches if we can get at it... -# -# PEP @ https://www.python.org/dev/peps/pep-0418/ -try: - now = time.monotonic -except AttributeError: - try: - # Try to use the pypi module if it's available (optionally...) - from monotonic import monotonic as now - except (AttributeError, ImportError): - # Ok fallback to the non-monotonic one... - now = time.time - @removals.remove( message="use datetime.datetime.isoformat()", diff --git a/requirements.txt b/requirements.txt index 98ddc940..e8de632c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -12,6 +12,7 @@ Babel>=1.3 six>=1.9.0 iso8601>=0.1.9 oslo.i18n>=1.5.0 # Apache-2.0 +monotonic>=0.1 # Apache-2.0 pytz>=2013.6 netaddr>=0.7.12 netifaces>=0.10.4