From 9f0aae5b5876b6a85fc7a30a4acb1f33f76fdb03 Mon Sep 17 00:00:00 2001 From: Corey Bryant Date: Thu, 30 Apr 2020 15:31:18 -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: Ida548b4bec00530418fd3d7ab254e971af77d3fe Closes-Bug: #1863021 --- cinder/cmd/api.py | 7 +++++++ cinder/cmd/backup.py | 7 +++++++ cinder/cmd/scheduler.py | 7 +++++++ cinder/cmd/volume.py | 7 +++++++ 4 files changed, 28 insertions(+) diff --git a/cinder/cmd/api.py b/cinder/cmd/api.py index d06c1e30984..4820f0d5828 100644 --- a/cinder/cmd/api.py +++ b/cinder/cmd/api.py @@ -22,6 +22,13 @@ import sys import eventlet # noqa 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 + from oslo_config import cfg from oslo_log import log as logging from oslo_reports import guru_meditation_report as gmr diff --git a/cinder/cmd/backup.py b/cinder/cmd/backup.py index ee433dd65c7..3b39f9aa3c0 100644 --- a/cinder/cmd/backup.py +++ b/cinder/cmd/backup.py @@ -26,6 +26,13 @@ import sys # share the same context. import 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 + from oslo_concurrency import processutils from oslo_config import cfg from oslo_log import log as logging diff --git a/cinder/cmd/scheduler.py b/cinder/cmd/scheduler.py index 9420a01995b..45e6f873a47 100644 --- a/cinder/cmd/scheduler.py +++ b/cinder/cmd/scheduler.py @@ -22,6 +22,13 @@ import sys import 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 + from oslo_config import cfg from oslo_log import log as logging from oslo_reports import guru_meditation_report as gmr diff --git a/cinder/cmd/volume.py b/cinder/cmd/volume.py index d31fb0d78dd..9e6b6b7f471 100644 --- a/cinder/cmd/volume.py +++ b/cinder/cmd/volume.py @@ -33,6 +33,13 @@ if os.name == 'nt': eventlet.monkey_patch(os=False) else: 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 + from oslo_config import cfg from oslo_log import log as logging from oslo_privsep import priv_context