diff options
author | Zuul <zuul@review.opendev.org> | 2022-11-18 19:33:01 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2022-11-18 19:33:01 +0000 |
commit | 91122a4fd3af8b6ce8c100f9797cbc1b4c52b99c (patch) | |
tree | 4db80bd9b241063954b849562d03af6c2b7cc8f1 | |
parent | f417cde1086bd663036ff74d9907f2d2740d7e6c (diff) | |
parent | 81cde9def95afae3f039cce22c781ce3a6a3e28a (diff) | |
download | cinder-91122a4fd3af8b6ce8c100f9797cbc1b4c52b99c.tar.gz |
Merge "Tests: Monkey patch before logs are loaded" into stable/yoga
-rw-r--r-- | cinder/tests/unit/__init__.py | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/cinder/tests/unit/__init__.py b/cinder/tests/unit/__init__.py index cff971fd9..9a999cb9f 100644 --- a/cinder/tests/unit/__init__.py +++ b/cinder/tests/unit/__init__.py @@ -22,12 +22,27 @@ :platform: Unix """ +import os + import eventlet +# Monkey patching must go before the oslo.log import, otherwise +# oslo.context will not use greenthread thread local and all greenthreads +# will share the same context. +if os.name == 'nt': + # eventlet monkey patching the os module causes subprocess.Popen to fail + # on Windows when using pipes due to missing non-blocking IO support. + 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 # pylint: disable=E0401 +import threading # noqa +orig_threading.current_thread.__globals__['_active'] = threading._active from cinder import objects -eventlet.monkey_patch() - # NOTE(alaski): Make sure this is done after eventlet monkey patching otherwise # the threading.local() store used in oslo_messaging will be initialized to # threadlocal storage rather than greenthread local. This will cause context |