From 9168889dbaa2db9ec8a72dea72c2bc1e13f60e6a Mon Sep 17 00:00:00 2001 From: Arthur Dayne Date: Fri, 8 May 2020 19:41:31 +0800 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: I876e2825da628d51c9977a4eec0c2ef05aed3229 Closes-Bug: #1863021 --- oslo_concurrency/tests/__init__.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/oslo_concurrency/tests/__init__.py b/oslo_concurrency/tests/__init__.py index bd455c4..73122fb 100644 --- a/oslo_concurrency/tests/__init__.py +++ b/oslo_concurrency/tests/__init__.py @@ -17,3 +17,9 @@ import os if os.environ.get('TEST_EVENTLET'): 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 # noqa + import threading # noqa + orig_threading.current_thread.__globals__['_active'] = threading._active