Browse Source

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
(cherry picked from commit ac3aa94599)
changes/69/679469/1
licanwei 6 months ago
parent
commit
78574f92e9
2 changed files with 20 additions and 7 deletions
  1. 20
    0
      watcher/cmd/__init__.py
  2. 0
    7
      watcher/common/service.py

+ 20
- 0
watcher/cmd/__init__.py View File

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

+ 0
- 7
watcher/common/service.py View File

@@ -17,7 +17,6 @@
17 17
 import datetime
18 18
 import socket
19 19
 
20
-import eventlet
21 20
 from oslo_concurrency import processutils
22 21
 from oslo_config import cfg
23 22
 from oslo_log import _options
@@ -42,12 +41,6 @@ from watcher.objects import base
42 41
 from watcher.objects import fields as wfields
43 42
 from watcher import version
44 43
 
45
-# NOTE:
46
-# Ubuntu 14.04 forces librabbitmq when kombu is used
47
-# Unfortunately it forces a version that has a crash
48
-# bug.  Calling eventlet.monkey_patch() tells kombu
49
-# to use libamqp instead.
50
-eventlet.monkey_patch()
51 44
 
52 45
 NOTIFICATION_OPTS = [
53 46
     cfg.StrOpt('notification_level',

Loading…
Cancel
Save