Import eventlet conditionally

Import eventlet conditionally to avoid extra noise
in logs where we don't need eventlet anyway.

Change-Id: Idcb56e02eff328ffe60de251ff694fcdc7d017f1
Signed-off-by: lajoskatona <lajos.katona@est.tech>
This commit is contained in:
lajoskatona
2026-05-26 14:09:00 +02:00
parent 43a6c8431c
commit 76bf3b5df7
2 changed files with 12 additions and 4 deletions
+5 -4
View File
@@ -14,6 +14,7 @@
# under the License.
import os
import sys
import debtcollector
@@ -21,11 +22,11 @@ __all__ = [
'subprocess',
]
try:
_patched_socket = False
if 'eventlet' in sys.modules:
import eventlet.patcher
except ImportError:
_patched_socket = False
else:
# In tests patching happens later, so we'll rely on environment variable
_patched_socket = eventlet.patcher.is_monkey_patched('socket') or bool(
os.environ.get('TEST_EVENTLET', False)
@@ -20,6 +20,13 @@ if os.environ.get('TEST_EVENTLET', False):
eventlet.monkey_patch()
import oslo_rootwrap
oslo_rootwrap._patched_socket = True
from eventlet.green import subprocess
oslo_rootwrap.subprocess = subprocess
from oslo_rootwrap.tests import test_functional
class RootwrapDaemonTest(test_functional.RootwrapDaemonTest):