Merge "Do not un-patch threading"
This commit is contained in:
commit
c058e79baf
@ -20,24 +20,10 @@ import time
|
|||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
from oslo_metrics import message_type
|
from oslo_metrics import message_type
|
||||||
from oslo_utils import eventletutils
|
|
||||||
from oslo_utils import importutils
|
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
eventlet = importutils.try_import('eventlet')
|
|
||||||
if eventlet and eventletutils.is_monkey_patched("thread"):
|
|
||||||
# Here we initialize module with the native python threading module
|
|
||||||
# if it was already monkey patched by eventlet/greenlet.
|
|
||||||
stdlib_threading = eventlet.patcher.original('threading')
|
|
||||||
else:
|
|
||||||
# Manage the case where we run this driver in a non patched environment
|
|
||||||
# and where user even so configure the driver to run heartbeat through
|
|
||||||
# a python thread, if we don't do that when the heartbeat will start
|
|
||||||
# we will facing an issue by trying to override the threading module.
|
|
||||||
stdlib_threading = threading
|
|
||||||
|
|
||||||
|
|
||||||
oslo_messaging_metrics = [
|
oslo_messaging_metrics = [
|
||||||
cfg.BoolOpt('metrics_enabled', default=False,
|
cfg.BoolOpt('metrics_enabled', default=False,
|
||||||
@ -114,6 +100,10 @@ class MetricsCollectorClient:
|
|||||||
self.send_thread = threading.Thread(target=self.send_loop)
|
self.send_thread = threading.Thread(target=self.send_loop)
|
||||||
self.send_thread.start()
|
self.send_thread.start()
|
||||||
|
|
||||||
|
# TODO(tkajinam): This is needed to ensure context switch in eventlet
|
||||||
|
# case and may be removed after eventlet support is removed.
|
||||||
|
time.sleep(0)
|
||||||
|
|
||||||
def send_loop(self):
|
def send_loop(self):
|
||||||
timeout = self.conf.metrics_thread_stop_timeout
|
timeout = self.conf.metrics_thread_stop_timeout
|
||||||
stoptime = time.time() + timeout
|
stoptime = time.time() + timeout
|
||||||
@ -247,8 +237,6 @@ METRICS_COLLECTOR = None
|
|||||||
|
|
||||||
|
|
||||||
def get_collector(conf, metrics_type, **kwargs):
|
def get_collector(conf, metrics_type, **kwargs):
|
||||||
global threading
|
|
||||||
threading = stdlib_threading
|
|
||||||
global METRICS_COLLECTOR
|
global METRICS_COLLECTOR
|
||||||
if METRICS_COLLECTOR is None:
|
if METRICS_COLLECTOR is None:
|
||||||
METRICS_COLLECTOR = MetricsCollectorClient(
|
METRICS_COLLECTOR = MetricsCollectorClient(
|
||||||
|
7
releasenotes/notes/bug-2098714-d55094fa4fbb3178.yaml
Normal file
7
releasenotes/notes/bug-2098714-d55094fa4fbb3178.yaml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- |
|
||||||
|
Fixes delayed metrics processing in services using eventlet, caused by
|
||||||
|
mixing a native thread with an eventlet-patched queue.
|
||||||
|
See `bug 2098714 <https://launchpad.net/bugs/2098714>`__
|
||||||
|
for details.
|
Loading…
x
Reference in New Issue
Block a user