Remove monotonic usage
The monotonic package was needed for monotonic time operations when running under Python runtimes older than 3.3. Since we now only support versions higher than this, this third party package requirement can now be removed. Change-Id: Ie99411882822a5db47462fcb2748c6e978587b8c Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
This commit is contained in:
parent
f6781bf057
commit
6793fe15b3
@ -22,7 +22,6 @@ keystoneauth1==3.4.0
|
||||
linecache2==1.0.0
|
||||
MarkupSafe==1.0
|
||||
mccabe==0.2.1
|
||||
monotonic==0.6
|
||||
mox3==0.20.0
|
||||
msgpack-python==0.4.0
|
||||
netaddr==0.7.18
|
||||
|
@ -20,15 +20,6 @@ time = eventlet.patcher.original('time')
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
# TODO(bnemec): When we have a minimum dependency on a version of eventlet
|
||||
# that uses monotonic by default, remove this monkey patching.
|
||||
if hasattr(time, 'monotonic'):
|
||||
# Use builtin monotonic clock, Python 3.3+
|
||||
_monotonic = time.monotonic
|
||||
else:
|
||||
import monotonic
|
||||
_monotonic = monotonic.monotonic
|
||||
|
||||
|
||||
def service_hub():
|
||||
# NOTE(dims): Add a custom impl for EVENTLET_HUB, so we can
|
||||
@ -36,7 +27,7 @@ def service_hub():
|
||||
# uses time.time() and we need to use a monotonic timer
|
||||
# to ensure that things like loopingcall work properly.
|
||||
hub = eventlet.hubs.get_default_hub().Hub()
|
||||
hub.clock = _monotonic
|
||||
hub.clock = time.monotonic
|
||||
# get_default_hub() will return a hub that is supported on this platform
|
||||
hub.is_available = lambda: True
|
||||
return hub
|
||||
|
@ -16,16 +16,12 @@ import logging
|
||||
import random
|
||||
import six
|
||||
import time
|
||||
from time import monotonic as now
|
||||
|
||||
from oslo_service._i18n import _
|
||||
from oslo_service import _options
|
||||
from oslo_utils import reflection
|
||||
|
||||
if hasattr(time, 'monotonic'):
|
||||
now = time.monotonic
|
||||
else:
|
||||
from monotonic import monotonic as now # noqa
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
DEFAULT_INTERVAL = 60.0
|
||||
|
@ -11,13 +11,13 @@
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import time
|
||||
from unittest import mock
|
||||
|
||||
import eventlet
|
||||
from eventlet.green import threading as greenthreading
|
||||
from oslotest import base as test_base
|
||||
|
||||
import oslo_service
|
||||
from oslo_service import fixture
|
||||
from oslo_service import loopingcall
|
||||
|
||||
@ -38,7 +38,7 @@ class LoopingCallTestCase(test_base.BaseTestCase):
|
||||
def test_monotonic_timer(self):
|
||||
def _raise_it():
|
||||
clock = eventlet.hubs.get_hub().clock
|
||||
ok = (clock == oslo_service._monotonic)
|
||||
ok = (clock == time.monotonic)
|
||||
raise loopingcall.LoopingCallDone(ok)
|
||||
|
||||
timer = loopingcall.FixedIntervalLoopingCall(_raise_it)
|
||||
@ -48,7 +48,7 @@ class LoopingCallTestCase(test_base.BaseTestCase):
|
||||
# Make sure that by default the oslo_service.service_hub() kicks in,
|
||||
# test in the main thread
|
||||
hub = eventlet.hubs.get_hub()
|
||||
self.assertEqual(oslo_service._monotonic,
|
||||
self.assertEqual(time.monotonic,
|
||||
hub.clock)
|
||||
|
||||
def test_return_false(self):
|
||||
@ -172,7 +172,7 @@ class DynamicLoopingCallTestCase(test_base.BaseTestCase):
|
||||
def test_monotonic_timer(self):
|
||||
def _raise_it():
|
||||
clock = eventlet.hubs.get_hub().clock
|
||||
ok = (clock == oslo_service._monotonic)
|
||||
ok = (clock == time.monotonic)
|
||||
raise loopingcall.LoopingCallDone(ok)
|
||||
|
||||
timer = loopingcall.DynamicLoopingCall(_raise_it)
|
||||
|
Loading…
x
Reference in New Issue
Block a user