From 1f3b2af29211dd97520b5b4638c94f883ec8d948 Mon Sep 17 00:00:00 2001 From: TomekTrzeciak Date: Wed, 28 Feb 2018 14:37:14 +0000 Subject: [PATCH] move tasks to the end when queued --- lib/cylc/task_pool.py | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/lib/cylc/task_pool.py b/lib/cylc/task_pool.py index 58b9d941c91..4e60557e856 100644 --- a/lib/cylc/task_pool.py +++ b/lib/cylc/task_pool.py @@ -569,25 +569,30 @@ def get_ready_tasks(self): Return the tasks that are dequeued. """ - # 1) queue unqueued tasks that are ready to run or manually forced now = time() - for itask in self.get_tasks(): - if itask.state.status != TASK_STATUS_QUEUED: - # only need to check that unqueued tasks are ready - if itask.manual_trigger or itask.ready_to_run(now): - # queue the task - itask.state.reset_state(TASK_STATUS_QUEUED) - itask.reset_manual_trigger() - - # 2) submit queued tasks if manually forced or not queue-limited ready_tasks = [] qconfig = self.config.cfg['scheduling']['queues'] + for queue in self.queues: - # 2.1) count active tasks and compare to queue limit n_active = 0 n_release = 0 n_limit = qconfig[queue]['limit'] tasks = self.queues[queue].values() + + # 1) queue unqueued tasks that are ready to run or manually forced + for itask in tasks: + if itask.state.status != TASK_STATUS_QUEUED: + # only need to check that unqueued tasks are ready + if itask.manual_trigger or itask.ready_to_run(now): + # queue the task + itask.state.reset_state(TASK_STATUS_QUEUED) + itask.reset_manual_trigger() + # move the task to the back of the queue + self.queues[queue][itask.identity] = \ + self.queues[queue].pop(itask.identity) + + # 2) submit queued tasks if manually forced or not queue-limited + # 2.1) count active tasks and compare to queue limit if n_limit: for itask in tasks: if itask.state.status in [TASK_STATUS_READY,