Merge "Warns user if thread monkeypatch is not done"

This commit is contained in:
Jenkins 2014-12-10 16:54:22 +00:00 committed by Gerrit Code Review
commit f6be71c503
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