From 777d582a37b8dcad18dbc3b98da40e144fab125d Mon Sep 17 00:00:00 2001 From: Rodolfo Alonso Hernandez Date: Mon, 13 Jan 2025 13:28:58 +0000 Subject: [PATCH] [eventlet-deprecation] Remove ``common.utils.spawn`` This method is not used in the Neutron code. Related-Bug: #2087942 Change-Id: Ibd322f4697d6484a6d606df8a7cabad935574b2e --- neutron/common/utils.py | 20 -------------------- neutron/tests/unit/common/test_utils.py | 14 ++------------ 2 files changed, 2 insertions(+), 32 deletions(-) diff --git a/neutron/common/utils.py b/neutron/common/utils.py index 659c03ea83e..0e2762c59c0 100644 --- a/neutron/common/utils.py +++ b/neutron/common/utils.py @@ -921,26 +921,6 @@ def collect_profiler_info(): } -def spawn(func, *args, **kwargs): - """As eventlet.spawn() but with osprofiler initialized in the new threads - - osprofiler stores the profiler instance in thread local storage, therefore - in new threads (including eventlet threads) osprofiler comes uninitialized - by default. This spawn() is a stand-in replacement for eventlet.spawn() - but we re-initialize osprofiler in threads spawn()-ed. - """ - - profiler_info = collect_profiler_info() - - @functools.wraps(func) - def wrapper(*args, **kwargs): - if profiler_info: - profiler.init(**profiler_info) - return func(*args, **kwargs) - - return eventlet.spawn(wrapper, *args, **kwargs) - - def spawn_n(func, *args, **kwargs): """See spawn() above""" diff --git a/neutron/tests/unit/common/test_utils.py b/neutron/tests/unit/common/test_utils.py index 4ae81fdf470..9a0ef212a8a 100644 --- a/neutron/tests/unit/common/test_utils.py +++ b/neutron/tests/unit/common/test_utils.py @@ -26,15 +26,12 @@ from neutron_lib import constants from oslo_config import cfg from oslo_log import log as logging from osprofiler import profiler -import testscenarios import testtools from neutron.common import utils from neutron.tests import base from neutron.tests.unit import tests -load_tests = testscenarios.load_tests_apply_scenarios - class _PortRange: """A linked list of port ranges.""" @@ -524,13 +521,7 @@ class TestRpBandwidthValidator(base.BaseTestCase): self.not_valid_rp_bandwidth, self.device_name_set) -class SpawnWithOrWithoutProfilerTestCase( - testscenarios.WithScenarios, base.BaseTestCase): - - scenarios = [ - ('spawn', {'spawn_variant': utils.spawn}), - ('spawn_n', {'spawn_variant': utils.spawn_n}), - ] +class SpawnWithOrWithoutProfilerTestCase(base.BaseTestCase): def _compare_profilers_in_parent_and_in_child(self, init_profiler): @@ -546,8 +537,7 @@ class SpawnWithOrWithoutProfilerTestCase( if init_profiler: profiler.init(hmac_key='fake secret') - self.spawn_variant( - lambda: q.put(is_profiler_initialized('in-child'))) + utils.spawn_n(lambda: q.put(is_profiler_initialized('in-child'))) q.put(is_profiler_initialized('in-parent')) # Make sure in parent we start with an uninitialized profiler by