From 4df24f7d1cd4554e567b14df2f2e8cdd96543a8c Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Mon, 13 Jul 2015 16:30:57 -0700 Subject: [PATCH] Use the warn_eventlet_not_patched util function This code can share the check for eventlet and warn when the thread module is not patched (which will be a problem). When it is not patched the following warning gets emitted: "RuntimeWarning: It is highly recommended that when eventlet" " is used that the ['thread'] modules are monkey patched when" " using the 'oslo.messaging eventlet executor' (to avoid spurious" " or unexpected lock-ups and/or hangs)" This will not be needed once a new futurist release happens but until then standardize on using that util library to emit these warnings. Change-Id: I7277fe19a73d8094a0acf033c75dc881e0d1e533 --- oslo_messaging/_executors/impl_eventlet.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/oslo_messaging/_executors/impl_eventlet.py b/oslo_messaging/_executors/impl_eventlet.py index 48771edc7..2c78c440d 100644 --- a/oslo_messaging/_executors/impl_eventlet.py +++ b/oslo_messaging/_executors/impl_eventlet.py @@ -19,7 +19,7 @@ from eventlet.green import threading as greenthreading import futurist from oslo_messaging._executors import impl_pooledexecutor -from oslo_messaging import localcontext +from oslo_utils import eventletutils LOG = logging.getLogger(__name__) @@ -37,13 +37,9 @@ class EventletExecutor(impl_pooledexecutor.PooledExecutor): def __init__(self, conf, listener, dispatcher): super(EventletExecutor, self).__init__(conf, listener, dispatcher) - if not isinstance(localcontext._STORE, greenthreading.local): - LOG.debug('eventlet executor in use but the threading module ' - 'has not been monkeypatched or has been ' - 'monkeypatched after the oslo.messaging library ' - 'have been loaded. This will results in unpredictable ' - 'behavior. In the future, we will raise a ' - 'RuntimeException in this case.') + eventletutils.warn_eventlet_not_patched( + expected_patched_modules=['thread'], + what="the 'oslo.messaging eventlet executor'") _executor_cls = futurist.GreenThreadPoolExecutor _lock_cls = greenthreading.Lock