Merge "Remove spawn_after"
This commit is contained in:
@@ -1560,18 +1560,6 @@ class SpawnOnTestCase(test.NoDBTestCase):
|
|||||||
'test_spawn_on_warns_on_full_executor.cell_worker', task)
|
'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):
|
class ExecutorStatsTestCase(test.NoDBTestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
|||||||
@@ -587,20 +587,6 @@ def spawn(
|
|||||||
return spawn_on(_get_default_executor(), func, *args, **kwargs)
|
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:
|
def _executor_is_full(executor: Executor) -> bool:
|
||||||
if concurrency_mode_threading():
|
if concurrency_mode_threading():
|
||||||
# TODO(gibi): Move this whole logic to futurist ThreadPoolExecutor
|
# TODO(gibi): Move this whole logic to futurist ThreadPoolExecutor
|
||||||
|
|||||||
Reference in New Issue
Block a user