Move eventlet monkey patch code

Eventlet monkey patching is not recommended on top level __init__ [1],
because Apache WSGI module uses own concurrency model [2] and API
service under Apache should be runned without eventlet. This patch
moves eventlet monkey patching code to watcher.cmd module __init__
(like in nova).

[1] https://specs.openstack.org/openstack/openstack-specs/specs/eventlet-best-practices.html
[2] http://modwsgi.readthedocs.io/en/develop/user-guides/processes-and-threading.html

Change-Id: Ie5cf67429ea9ef8d00dd7348ce288437ea105c08
This commit is contained in:
licanwei 2019-03-29 11:48:56 +08:00
parent ab03bf9bb0
commit ac3aa94599
2 changed files with 20 additions and 7 deletions

View File

@ -0,0 +1,20 @@
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
# NOTE(licanwei): Do eventlet monkey patching here, instead of in
# common/service.py. This allows the API service to run without monkey
# patching under Apache (which uses its own concurrency model). Mixing
# concurrency models can cause undefined behavior and potentially API timeouts.
import eventlet
eventlet.monkey_patch()

View File

@ -17,7 +17,6 @@
import datetime
import socket
import eventlet
from oslo_concurrency import processutils
from oslo_config import cfg
from oslo_log import _options
@ -42,12 +41,6 @@ from watcher.objects import base
from watcher.objects import fields as wfields
from watcher import version
# NOTE:
# Ubuntu 14.04 forces librabbitmq when kombu is used
# Unfortunately it forces a version that has a crash
# bug. Calling eventlet.monkey_patch() tells kombu
# to use libamqp instead.
eventlet.monkey_patch()
NOTIFICATION_OPTS = [
cfg.StrOpt('notification_level',