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: I598530b3f417964ff697b48e681b135bd119ae81 Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
This commit is contained in:
parent
c7272ed465
commit
c1768401f7
@ -32,7 +32,6 @@ linecache2==1.0.0
|
||||
MarkupSafe==1.0
|
||||
mccabe==0.2.1
|
||||
mock==2.0.0
|
||||
monotonic==0.6
|
||||
mox3==0.20.0
|
||||
msgpack-python==0.4.0
|
||||
netaddr==0.7.18
|
||||
|
@ -51,11 +51,6 @@ from oslo_messaging import exceptions
|
||||
from oslo_messaging.target import Target
|
||||
from oslo_messaging import transport
|
||||
|
||||
if hasattr(time, 'monotonic'):
|
||||
now = time.monotonic
|
||||
else:
|
||||
from monotonic import monotonic as now # noqa
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@ -980,7 +975,7 @@ class Controller(pyngus.ConnectionEventHandler):
|
||||
# methods executed by Tasks created by the driver:
|
||||
|
||||
def send(self, send_task):
|
||||
if send_task.deadline and send_task.deadline <= now():
|
||||
if send_task.deadline and send_task.deadline <= time.monotonic():
|
||||
send_task._on_timeout()
|
||||
return
|
||||
key = keyify(send_task.target, send_task.service)
|
||||
|
@ -35,18 +35,13 @@ import threading
|
||||
import time
|
||||
import uuid
|
||||
|
||||
if hasattr(time, 'monotonic'):
|
||||
now = time.monotonic
|
||||
else:
|
||||
from monotonic import monotonic as now # noqa
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def compute_timeout(offset):
|
||||
# minimize the timer granularity to one second so we don't have to track
|
||||
# too many timers
|
||||
return math.ceil(now() + offset)
|
||||
return math.ceil(time.monotonic() + offset)
|
||||
|
||||
|
||||
class _SocketConnection(object):
|
||||
@ -75,7 +70,7 @@ class _SocketConnection(object):
|
||||
if self.socket:
|
||||
try:
|
||||
pyngus.read_socket_input(self.pyngus_conn, self.socket)
|
||||
self.pyngus_conn.process(now())
|
||||
self.pyngus_conn.process(time.monotonic())
|
||||
except (socket.timeout, socket.error) as e:
|
||||
# pyngus handles EAGAIN/EWOULDBLOCK and EINTER
|
||||
self.pyngus_conn.close_input()
|
||||
@ -87,7 +82,7 @@ class _SocketConnection(object):
|
||||
if self.socket:
|
||||
try:
|
||||
pyngus.write_socket_output(self.pyngus_conn, self.socket)
|
||||
self.pyngus_conn.process(now())
|
||||
self.pyngus_conn.process(time.monotonic())
|
||||
except (socket.timeout, socket.error) as e:
|
||||
# pyngus handles EAGAIN/EWOULDBLOCK and EINTER
|
||||
self.pyngus_conn.close_output()
|
||||
@ -213,7 +208,7 @@ class Scheduler(object):
|
||||
due = self._deadlines[0] if self._deadlines else None
|
||||
if due is None:
|
||||
return max_delay
|
||||
_now = now()
|
||||
_now = time.monotonic()
|
||||
if due <= _now:
|
||||
return 0
|
||||
else:
|
||||
@ -222,7 +217,7 @@ class Scheduler(object):
|
||||
def _process(self):
|
||||
"""Invoke all expired callables."""
|
||||
if self._deadlines:
|
||||
_now = now()
|
||||
_now = time.monotonic()
|
||||
try:
|
||||
while self._deadlines[0] <= _now:
|
||||
deadline = heapq.heappop(self._deadlines)
|
||||
@ -376,7 +371,7 @@ class Thread(threading.Thread):
|
||||
|
||||
# force select to return in time to service the next expiring timer
|
||||
if deadline:
|
||||
_now = now()
|
||||
_now = time.monotonic()
|
||||
timeout = 0 if deadline <= _now else (deadline - _now)
|
||||
else:
|
||||
timeout = None
|
||||
@ -397,7 +392,7 @@ class Thread(threading.Thread):
|
||||
self._requests.process_requests()
|
||||
self._connection.read_socket()
|
||||
if pyngus_conn and pyngus_conn.deadline:
|
||||
_now = now()
|
||||
_now = time.monotonic()
|
||||
if pyngus_conn.deadline <= _now:
|
||||
pyngus_conn.process(_now)
|
||||
self._connection.write_socket()
|
||||
|
@ -12,7 +12,6 @@ oslo.serialization!=2.19.1,>=2.18.0 # Apache-2.0
|
||||
oslo.service!=1.28.1,>=1.24.0 # Apache-2.0
|
||||
stevedore>=1.20.0 # Apache-2.0
|
||||
debtcollector>=1.2.0 # Apache-2.0
|
||||
monotonic>=0.6;python_version<'3.3' # Apache-2.0
|
||||
|
||||
# for jsonutils
|
||||
six>=1.10.0 # MIT
|
||||
|
Loading…
Reference in New Issue
Block a user