diff --git a/nova/cmd/__init__.py b/nova/cmd/__init__.py index d1e331c39d63..1b1ddf772c12 100644 --- a/nova/cmd/__init__.py +++ b/nova/cmd/__init__.py @@ -14,6 +14,8 @@ # under the License. import eventlet +from oslo_utils import importutils +from six.moves import reload_module from nova import debugger @@ -22,3 +24,9 @@ if debugger.enabled(): 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'))