diff --git a/oslo_service/__init__.py b/oslo_service/__init__.py index 2da3fca7..1529e7d1 100644 --- a/oslo_service/__init__.py +++ b/oslo_service/__init__.py @@ -13,7 +13,6 @@ import os import eventlet.patcher -import monotonic from oslo_log import log as logging time = eventlet.patcher.original('time') @@ -27,6 +26,7 @@ if hasattr(time, 'monotonic'): # Use builtin monotonic clock, Python 3.3+ _monotonic = time.monotonic else: + import monotonic _monotonic = monotonic.monotonic diff --git a/oslo_service/periodic_task.py b/oslo_service/periodic_task.py index f8d4abc3..caa99e40 100644 --- a/oslo_service/periodic_task.py +++ b/oslo_service/periodic_task.py @@ -16,7 +16,11 @@ import logging import random import time -from monotonic import monotonic as now # noqa +if hasattr(time, 'monotonic'): + now = time.monotonic +else: + from monotonic import monotonic as now # noqa + from oslo_utils import reflection import six diff --git a/requirements.txt b/requirements.txt index 9e71d4c8..08537f0f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,7 +5,7 @@ WebOb>=1.7.1 # MIT eventlet!=0.18.3,!=0.20.1,>=0.18.2 # MIT greenlet>=0.4.10 # MIT -monotonic>=0.6 # Apache-2.0 +monotonic>=0.6;python_version<'3.3' # Apache-2.0 oslo.utils>=3.33.0 # Apache-2.0 oslo.concurrency>=3.25.0 # Apache-2.0 oslo.config>=5.1.0 # Apache-2.0