Reload oslo_context after calling monkey_patch()
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 and
instead of having one request per green thread, we will have one request
object which will be overwritten every time when a new context is
created.
To workaround the problem, always reload oslo_context.context after
calling monkey_patch() to make sure it uses green thread locals.
Change-Id: Id059e5576c3fc78dd893fde15c963e182f1157f6
Closes-Bug: #1773102
(cherry picked from commit 233ea582f7
)
This commit is contained in:
parent
b58c7f0337
commit
bee3e963ef
|
@ -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'))
|
||||
|
|
Loading…
Reference in New Issue