Merge "Make monkey patch work in uWSGI mode"
This commit is contained in:
commit
a674241d0f
|
@ -23,11 +23,13 @@ from nova import context
|
|||
from nova import exception
|
||||
from nova import objects
|
||||
from nova import service
|
||||
from nova import utils
|
||||
|
||||
CONF = cfg.CONF
|
||||
|
||||
CONFIG_FILES = ['api-paste.ini', 'nova.conf']
|
||||
|
||||
utils.monkey_patch()
|
||||
objects.register_all()
|
||||
|
||||
|
||||
|
|
|
@ -13,20 +13,6 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import eventlet
|
||||
from oslo_utils import importutils
|
||||
from six.moves import reload_module
|
||||
from nova import utils
|
||||
|
||||
from nova import debugger
|
||||
|
||||
if debugger.enabled():
|
||||
# turn off thread patching to enable the remote debugger
|
||||
eventlet.monkey_patch(os=False, thread=False)
|
||||
else:
|
||||
eventlet.monkey_patch(os=False)
|
||||
|
||||
# NOTE(rgerganov): oslo.context is storing a global thread-local variable
|
||||
# which keeps the request context for the current thread. If oslo.context is
|
||||
# imported before calling monkey_patch(), then this thread-local won't be
|
||||
# green. To workaround this, reload the module after calling monkey_patch()
|
||||
reload_module(importutils.import_module('oslo_context.context'))
|
||||
utils.monkey_patch()
|
||||
|
|
|
@ -48,8 +48,10 @@ from oslo_utils import timeutils
|
|||
from oslo_utils import units
|
||||
import six
|
||||
from six.moves import range
|
||||
from six.moves import reload_module
|
||||
|
||||
import nova.conf
|
||||
from nova import debugger
|
||||
from nova import exception
|
||||
from nova.i18n import _, _LE, _LI, _LW
|
||||
import nova.network
|
||||
|
@ -1296,3 +1298,18 @@ def generate_hostid(host, project_id):
|
|||
sha_hash = hashlib.sha224(data)
|
||||
return sha_hash.hexdigest()
|
||||
return ""
|
||||
|
||||
|
||||
def monkey_patch():
|
||||
if debugger.enabled():
|
||||
# turn off thread patching to enable the remote debugger
|
||||
eventlet.monkey_patch(os=False, thread=False)
|
||||
else:
|
||||
eventlet.monkey_patch(os=False)
|
||||
|
||||
# NOTE(rgerganov): oslo.context is storing a global thread-local variable
|
||||
# which keeps the request context for the current thread. If oslo.context
|
||||
# is imported before calling monkey_patch(), then this thread-local won't
|
||||
# be green. To workaround this, reload the module after calling
|
||||
# monkey_patch()
|
||||
reload_module(importutils.import_module('oslo_context.context'))
|
||||
|
|
Loading…
Reference in New Issue