Fix eventlet detection

Eventlet may be installed, but not used for example projects
like octavia. Improve autodetection mechanism by trying to import
module and check if it is actually patched.

Closes-Bug: #2039346
Change-Id: I860abe953ce945bb5152c77a7daeb6aa1003512b
(cherry picked from commit a1fe1b9cfb)
(cherry picked from commit a6c4f8a9c6)
This commit is contained in:
Vasyl Saienko 2024-03-26 12:33:16 +02:00 committed by damani42
parent f6a0a5786e
commit 287e138adf
1 changed files with 2 additions and 2 deletions

View File

@ -40,6 +40,7 @@ except ImportError:
syslog = None
from oslo_config import cfg
from oslo_utils import eventletutils
from oslo_utils import importutils
from oslo_utils import units
@ -272,8 +273,7 @@ def _fix_eventlet_logging():
"""
# If eventlet was not loaded before call to setup assume it's not used.
eventlet = sys.modules.get('eventlet')
if eventlet:
if eventletutils.is_monkey_patched('thread'):
import eventlet.green.threading
from oslo_log import pipe_mutex
logging.threading = eventlet.green.threading