Skip to content

Commit

Permalink
Don't use monotonic with Python >=3.3
Browse files Browse the repository at this point in the history
A change to the global-requirements has limited use of monotonic
library to Python versions earlier than 3.3 (later versions have
built-in support for a monotonic clock), so limit it in
requirements.txt.

Note: this patch updates kafka driver (due to deprecated exception
in library) in order to pass unit tests

Change-Id: Id6b0814e05a0e548a8c2a5359daf1a6878cf6859
  • Loading branch information
ajssmith committed Dec 3, 2018
1 parent 274b7c3 commit 2528448
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
7 changes: 6 additions & 1 deletion oslo_messaging/_drivers/amqp1_driver/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,19 @@
import abc
import collections
import logging
from monotonic import monotonic as now # noqa
import os
import platform
import random
import sys
import threading
import time
import uuid

if hasattr(time, 'monotonic'):
now = time.monotonic
else:
from monotonic import monotonic as now # noqa

import proton
import pyngus
from six import iteritems
Expand Down
7 changes: 6 additions & 1 deletion oslo_messaging/_drivers/amqp1_driver/eventloop.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,18 @@
import heapq
import logging
import math
from monotonic import monotonic as now # noqa
import os
import select
import socket
import threading
import time
import uuid

if hasattr(time, 'monotonic'):
now = time.monotonic
else:
from monotonic import monotonic as now # noqa

import pyngus

from oslo_messaging._i18n import _LE, _LI, _LW
Expand Down
4 changes: 2 additions & 2 deletions oslo_messaging/_drivers/impl_kafka.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def _poll_messages(self, timeout):
if not messages:
# NOTE(sileht): really ? you return payload but no messages...
# simulate timeout to consume message again
raise kafka.errors.ConsumerTimeout()
raise kafka.errors.ConsumerNoMoreData()

if not self.enable_auto_commit:
self.consumer.commit()
Expand All @@ -200,7 +200,7 @@ def _raise_timeout(exc):
return
try:
return self._poll_messages(poll_timeout)
except kafka.errors.ConsumerTimeout as exc:
except kafka.errors.ConsumerNoMoreData as exc:
poll_timeout = timer.check_return(
_raise_timeout, exc, maximum=self.consumer_timeout)
except Exception:
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ oslo.service!=1.28.1,>=1.24.0 # Apache-2.0
oslo.i18n>=3.15.3 # Apache-2.0
stevedore>=1.20.0 # Apache-2.0
debtcollector>=1.2.0 # Apache-2.0
monotonic>=0.6 # Apache-2.0
monotonic>=0.6;python_version<'3.3' # Apache-2.0

# for jsonutils
six>=1.10.0 # MIT
Expand Down

0 comments on commit 2528448

Please sign in to comment.