From 3216573655bb6f35828c78589008e622d31832d1 Mon Sep 17 00:00:00 2001 From: Balazs Gibizer Date: Mon, 2 Feb 2026 15:02:50 +0100 Subject: [PATCH] Remove spawn_after It was a naive implementation it is replaced with StaticallyDelayingCancellableTaskExecutorWrapper. Signed-off-by: Balazs Gibizer Change-Id: I5e8d496473d4ec167d1655368a00cbfa78d2c074 --- nova/tests/unit/test_utils.py | 12 ------------ nova/utils.py | 14 -------------- 2 files changed, 26 deletions(-) diff --git a/nova/tests/unit/test_utils.py b/nova/tests/unit/test_utils.py index b086e2266a..1d71693cab 100644 --- a/nova/tests/unit/test_utils.py +++ b/nova/tests/unit/test_utils.py @@ -1560,18 +1560,6 @@ class SpawnOnTestCase(test.NoDBTestCase): 'test_spawn_on_warns_on_full_executor.cell_worker', task) -class SpawnAfterTestCase(test.NoDBTestCase): - @mock.patch.object(time, "sleep") - def test_spawn_after_submits_work_after_delay(self, mock_sleep): - task = mock.MagicMock() - - future = utils.spawn_after(0.1, task, 13, foo='bar') - future.result() - - task.assert_called_once_with(13, foo='bar') - mock_sleep.assert_called_once_with(0.1) - - class ExecutorStatsTestCase(test.NoDBTestCase): def setUp(self): diff --git a/nova/utils.py b/nova/utils.py index 35ee8ad6ee..75ae131235 100644 --- a/nova/utils.py +++ b/nova/utils.py @@ -587,20 +587,6 @@ def spawn( return spawn_on(_get_default_executor(), func, *args, **kwargs) -def spawn_after( - seconds: float, - func: ty.Callable[..., ty.Any], - *args: ty.Any, **kwargs: ty.Any -) -> futurist.Future: - """Executing the function asynchronously after the given time.""" - - def delayed(*args, **kwargs): - time.sleep(seconds) - return func(*args, **kwargs) - - return spawn(delayed, *args, **kwargs) - - def _executor_is_full(executor: Executor) -> bool: if concurrency_mode_threading(): # TODO(gibi): Move this whole logic to futurist ThreadPoolExecutor