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
This commit is contained in:
Vasyl Saienko
2024-03-26 12:33:16 +02:00
committed by Takashi Kajinami
parent 3e58709e80
commit a1fe1b9cfb

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