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
This commit is contained in:
parent
9eef14f1c0
commit
4df24f7d1c
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user