diff options
author | Zane Bitter <zbitter@redhat.com> | 2018-12-03 12:29:00 +1300 |
---|---|---|
committer | Zane Bitter <zbitter@redhat.com> | 2018-12-05 16:28:41 +1300 |
commit | d7e70b11c638112113e765a90d4fa6f94e1ca553 (patch) | |
tree | 22ef4e4223328787e16b9a4c67e69dd783713cd9 /oslo_utils/timeutils.py | |
parent | fde490f22d2ed3aacd0590e051b2722cb071d4bd (diff) | |
download | oslo-utils-d7e70b11c638112113e765a90d4fa6f94e1ca553.tar.gz |
Don't use monotonic on Python >=3.3
A change to the global-requirements[1] has limited use of the monotonic
library to Python versions earlier than 3.3 (later versions have
built-in support for a monotonic clock), so no requirements changes can
be merged until we similarly limit it in requirements.txt.
[1] https://review.openstack.org/615441
Change-Id: Ib53d89ea820d21114d10280c9f4ab1b0c2c4a4bc
Diffstat (limited to 'oslo_utils/timeutils.py')
-rw-r--r-- | oslo_utils/timeutils.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/oslo_utils/timeutils.py b/oslo_utils/timeutils.py index 117ae03..1e730a1 100644 --- a/oslo_utils/timeutils.py +++ b/oslo_utils/timeutils.py @@ -24,12 +24,16 @@ import time from debtcollector import removals import iso8601 -from monotonic import monotonic as now # noqa import pytz import six from oslo_utils import reflection +if hasattr(time, 'monotonic'): + now = time.monotonic +else: + from monotonic import monotonic as now # noqa + # ISO 8601 extended time format with microseconds _ISO8601_TIME_FORMAT_SUBSECOND = '%Y-%m-%dT%H:%M:%S.%f' _ISO8601_TIME_FORMAT = '%Y-%m-%dT%H:%M:%S' |