Warns user if thread monkeypatch is not done

This change warns the user that it does have monkeypatched the
oslo.messaging library correclty.

Change-Id: Ice80ffc6cbc39919eac4bc0809992daea51b5922
Closes-bug: #1288878
This commit is contained in:
Mehdi Abaakouk 2014-12-10 09:33:22 +01:00
parent 836f16f3fe
commit d3e6ea1788
4 changed files with 24 additions and 0 deletions

View File

@ -7,3 +7,8 @@ Notification Listener
.. currentmodule:: oslo.messaging
.. autofunction:: get_notification_listener
.. autoclass:: MessageHandlingServer
:members:
.. autofunction:: get_local_context

View File

@ -13,16 +13,21 @@
# License for the specific language governing permissions and limitations
# under the License.
import logging
import sys
import eventlet
from eventlet.green import threading as greenthreading
from eventlet import greenpool
import greenlet
from oslo.config import cfg
from oslo.messaging._executors import base
from oslo.messaging import localcontext
from oslo.utils import excutils
LOG = logging.getLogger(__name__)
_eventlet_opts = [
cfg.IntOpt('rpc_thread_pool_size',
default=64,
@ -77,6 +82,14 @@ class EventletExecutor(base.ExecutorBase):
self._greenpool = greenpool.GreenPool(self.conf.rpc_thread_pool_size)
self._running = False
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.')
def start(self):
if self._thread is not None:
return

View File

@ -110,6 +110,9 @@ def get_notification_listener(transport, targets, endpoints,
dispatched. By default, the most simple executor is used - the blocking
executor.
If the eventlet executor is used, the threading and time library need to be
monkeypatched.
:param transport: the messaging transport
:type transport: Transport
:param targets: the exchanges and topics to listen on

View File

@ -106,6 +106,9 @@ def get_rpc_server(transport, target, endpoints,
dispatched. By default, the most simple executor is used - the blocking
executor.
If the eventlet executor is used, the threading and time library need to be
monkeypatched.
:param transport: the messaging transport
:type transport: Transport
:param target: the exchange, topic and server to listen on