Browse Source

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
changes/10/140610/3
Mehdi Abaakouk 7 years ago
parent
commit
d3e6ea1788
  1. 5
      doc/source/notification_listener.rst
  2. 13
      oslo/messaging/_executors/impl_eventlet.py
  3. 3
      oslo/messaging/notify/listener.py
  4. 3
      oslo/messaging/rpc/server.py

5
doc/source/notification_listener.rst

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

13
oslo/messaging/_executors/impl_eventlet.py

@ -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

3
oslo/messaging/notify/listener.py

@ -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

3
oslo/messaging/rpc/server.py

@ -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

Loading…
Cancel
Save