diff --git a/cylc/flow/task_pool.py b/cylc/flow/task_pool.py index 7bdca66a1c5..f1a6942f0ab 100644 --- a/cylc/flow/task_pool.py +++ b/cylc/flow/task_pool.py @@ -319,12 +319,15 @@ def compute_runahead(self, force=False) -> bool: if not self.active_tasks: # Find the earliest sequence point beyond the workflow start point. base_point = min( - point - for point in { - seq.get_first_point(self.config.start_point) - for seq in self.config.sequences - } - if point is not None + ( + point + for point in { + seq.get_first_point(self.config.start_point) + for seq in self.config.sequences + } + if point is not None + ), + default=None, ) else: # Find the earliest point with incomplete tasks. diff --git a/tests/integration/test_task_pool.py b/tests/integration/test_task_pool.py index a7d205c1350..25bd1978f77 100644 --- a/tests/integration/test_task_pool.py +++ b/tests/integration/test_task_pool.py @@ -1750,6 +1750,26 @@ async def test_compute_runahead( assert int(str(schd.pool.runahead_limit_point)) == 5 # +1 +async def test_compute_runahead_with_no_tasks(flow, scheduler, run): + """It should handle the case of an empty workflow. + + See https://github.com/cylc/cylc-flow/issues/6225 + """ + id_ = flow( + { + 'scheduling': { + 'initial cycle point': '2000', + 'graph': {'R1': 'foo'}, + }, + } + ) + schd = scheduler(id_, startcp='2002', paused_start=False) + async with run(schd): + assert schd.pool.compute_runahead() is False + assert schd.pool.runahead_limit_point is None + assert schd.pool.get_tasks() == [] + + @pytest.mark.parametrize('rhlimit', ['P2D', 'P2']) @pytest.mark.parametrize('compat_mode', ['compat-mode', 'normal-mode']) async def test_runahead_future_trigger(