From 14e3ab97048d2ca27188ed5ed431a669dfa3aabe Mon Sep 17 00:00:00 2001 From: Corey Bryant Date: Mon, 4 May 2020 13:37:31 -0400 Subject: [PATCH] Monkey patch original current_thread _active Monkey patch the original current_thread to use the up-to-date _active global variable. This solution is based on that documented at: https://github.com/eventlet/eventlet/issues/592 Change-Id: I35335325828c10f7a0a1c97edfd1a842dda77577 Story: 2007614 --- barbican/cmd/keystone_listener.py | 6 ++++++ barbican/cmd/retry_scheduler.py | 6 ++++++ barbican/cmd/worker.py | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/barbican/cmd/keystone_listener.py b/barbican/cmd/keystone_listener.py index 3b49b085d..6e9a9c3c2 100644 --- a/barbican/cmd/keystone_listener.py +++ b/barbican/cmd/keystone_listener.py @@ -27,6 +27,12 @@ import sys # To have remote debugging, thread module needs to be disabled. # eventlet.monkey_patch(thread=False) eventlet.monkey_patch() +# Monkey patch the original current_thread to use the up-to-date _active +# global variable. See https://bugs.launchpad.net/bugs/1863021 and +# https://github.com/eventlet/eventlet/issues/592 +import __original_module_threading as orig_threading +import threading # noqa +orig_threading.current_thread.__globals__['_active'] = threading._active # 'Borrowed' from the Glance project: diff --git a/barbican/cmd/retry_scheduler.py b/barbican/cmd/retry_scheduler.py index fecf29eba..9973adacc 100644 --- a/barbican/cmd/retry_scheduler.py +++ b/barbican/cmd/retry_scheduler.py @@ -25,6 +25,12 @@ import sys # Oslo messaging RPC server uses eventlet. eventlet.monkey_patch() +# Monkey patch the original current_thread to use the up-to-date _active +# global variable. See https://bugs.launchpad.net/bugs/1863021 and +# https://github.com/eventlet/eventlet/issues/592 +import __original_module_threading as orig_threading +import threading # noqa +orig_threading.current_thread.__globals__['_active'] = threading._active # 'Borrowed' from the Glance project: # If ../barbican/__init__.py exists, add ../ to Python search path, so that diff --git a/barbican/cmd/worker.py b/barbican/cmd/worker.py index f9f0d0896..f7a711ca8 100644 --- a/barbican/cmd/worker.py +++ b/barbican/cmd/worker.py @@ -25,6 +25,12 @@ import sys # Oslo messaging RPC server uses eventlet. eventlet.monkey_patch() +# Monkey patch the original current_thread to use the up-to-date _active +# global variable. See https://bugs.launchpad.net/bugs/1863021 and +# https://github.com/eventlet/eventlet/issues/592 +import __original_module_threading as orig_threading +import threading # noqa +orig_threading.current_thread.__globals__['_active'] = threading._active # 'Borrowed' from the Glance project: # If ../barbican/__init__.py exists, add ../ to Python search path, so that