From a9ad4412f175472e7d817cc18fa38dc6b3d4bf76 Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Wed, 10 Jun 2015 15:11:09 -0700 Subject: [PATCH] Use monotonic library to avoid finding monotonic time function That library already does this same/equivalent search and ensures that a monotonically increasing time is made available so we can just avoid looking around for it ourselves. Depends-On: I0f07858e96ea3baf46f8a453e253b9ed29c7f7e2 Depends-On: I33bd2d9dff9cb7dc1a50177db7286b7317966784 Change-Id: Idd2109c8947d10cdbd62c53998ab2e31382e8633 --- oslo_utils/timeutils.py | 14 +------------- requirements.txt | 1 + 2 files changed, 2 insertions(+), 13 deletions(-) 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