Skip to content

Commit

Permalink
move tasks to the end when queued
Browse files Browse the repository at this point in the history
  • Loading branch information
TomekTrzeciak committed Feb 28, 2018
1 parent a446022 commit 1f3b2af
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions lib/cylc/task_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 1f3b2af

Please sign in to comment.