Apply eventlet workaround only once

... to avoid issues caused by setup method called multiple times.

Closes-Bug: #1995514
Change-Id: I125f7a8fa12f4d17af70987c20e5dedb14232d7b
This commit is contained in:
Takashi Kajinami 2024-03-31 01:23:21 +09:00
parent a1fe1b9cfb
commit 142fde8224
1 changed files with 6 additions and 1 deletions

View File

@ -70,6 +70,8 @@ LOG_ROTATE_INTERVAL_MAPPING = {
'midnight': 'midnight'
}
_EVENTLET_FIX_APPLIED = False
def _get_log_file_path(conf, binary=None):
logfile = conf.log_file
@ -272,13 +274,16 @@ def _fix_eventlet_logging():
Workaround for: https://github.com/eventlet/eventlet/issues/432
"""
global _EVENTLET_FIX_APPLIED
# If eventlet was not loaded before call to setup assume it's not used.
if eventletutils.is_monkey_patched('thread'):
if eventletutils.is_monkey_patched('thread') and not _EVENTLET_FIX_APPLIED:
import eventlet.green.threading
from oslo_log import pipe_mutex
logging.threading = eventlet.green.threading
logging._lock = logging.threading.RLock()
logging.Handler.createLock = pipe_mutex.pipe_createLock
_EVENTLET_FIX_APPLIED = True
def setup(conf, product_name, version='unknown', *, fix_eventlet=True):