From 90146b62c765ad1b8be1ffec1799cba9f3994c2d Mon Sep 17 00:00:00 2001 From: Corey Bryant Date: Mon, 30 Mar 2020 15:14:15 -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: I95a8d8cf02a0cb923418c0b5655442b8d7bc6b08 Closes-Bug: #1863021 --- glance/cmd/api.py | 7 +++++++ glance/cmd/registry.py | 7 +++++++ glance/cmd/scrubber.py | 7 +++++++ 3 files changed, 21 insertions(+) diff --git a/glance/cmd/api.py b/glance/cmd/api.py index 462273e0e5..dfb08ec6b1 100644 --- a/glance/cmd/api.py +++ b/glance/cmd/api.py @@ -39,6 +39,13 @@ if os.name == 'nt': else: eventlet.patcher.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 +orig_threading.current_thread.__globals__['_active'] = threading._active + from oslo_reports import guru_meditation_report as gmr from oslo_utils import encodeutils diff --git a/glance/cmd/registry.py b/glance/cmd/registry.py index 662e83da84..40b6ce2abc 100644 --- a/glance/cmd/registry.py +++ b/glance/cmd/registry.py @@ -39,6 +39,13 @@ if os.name == 'nt': else: eventlet.patcher.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 +orig_threading.current_thread.__globals__['_active'] = threading._active + from oslo_reports import guru_meditation_report as gmr from oslo_utils import encodeutils diff --git a/glance/cmd/scrubber.py b/glance/cmd/scrubber.py index f27c854ad3..0f49b00502 100644 --- a/glance/cmd/scrubber.py +++ b/glance/cmd/scrubber.py @@ -37,6 +37,13 @@ if os.name == 'nt': else: eventlet.patcher.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 +orig_threading.current_thread.__globals__['_active'] = threading._active + import subprocess # If ../glance/__init__.py exists, add ../ to Python search path, so that