Browse Source

Limit monotonic to py2

A recent requirements change [1] restricted monotonic to <py3.3, meaning
that any subsequent change triggering the requirements-check job will
fail until that's synced. Do that.

In order to make this sane, we need to be sure we're only using
monotonic if it's available. In oslo_service.__init__.py, we're using
the actual library if eventlet is. In periodic_task.py we're using the
actual library if the monotonic() method isn't available in the time
module.

[1] Ib8c1bf08f5fa7463911602b0df19315907c81e04

Change-Id: I3b24a089b780aac2746f48f7d5b538546ccce982
Eric Fried 5 months ago
parent
commit
643578c899
3 changed files with 7 additions and 3 deletions
  1. 1
    1
      oslo_service/__init__.py
  2. 5
    1
      oslo_service/periodic_task.py
  3. 1
    1
      requirements.txt

+ 1
- 1
oslo_service/__init__.py View File

@@ -13,7 +13,6 @@
13 13
 import os
14 14
 
15 15
 import eventlet.patcher
16
-import monotonic
17 16
 from oslo_log import log as logging
18 17
 
19 18
 time = eventlet.patcher.original('time')
@@ -27,6 +26,7 @@ if hasattr(time, 'monotonic'):
27 26
     # Use builtin monotonic clock, Python 3.3+
28 27
     _monotonic = time.monotonic
29 28
 else:
29
+    import monotonic
30 30
     _monotonic = monotonic.monotonic
31 31
 
32 32
 

+ 5
- 1
oslo_service/periodic_task.py View File

@@ -16,7 +16,11 @@ import logging
16 16
 import random
17 17
 import time
18 18
 
19
-from monotonic import monotonic as now  # noqa
19
+if hasattr(time, 'monotonic'):
20
+    now = time.monotonic
21
+else:
22
+    from monotonic import monotonic as now  # noqa
23
+
20 24
 from oslo_utils import reflection
21 25
 import six
22 26
 

+ 1
- 1
requirements.txt View File

@@ -5,7 +5,7 @@
5 5
 WebOb>=1.7.1 # MIT
6 6
 eventlet!=0.18.3,!=0.20.1,>=0.18.2 # MIT
7 7
 greenlet>=0.4.10 # MIT
8
-monotonic>=0.6 # Apache-2.0
8
+monotonic>=0.6;python_version<'3.3'  # Apache-2.0
9 9
 oslo.utils>=3.33.0 # Apache-2.0
10 10
 oslo.concurrency>=3.25.0 # Apache-2.0
11 11
 oslo.config>=5.1.0 # Apache-2.0

Loading…
Cancel
Save