def _compute_next_job_for_tasks(queue_entries, special_tasks):
 next_job_id = None
 hqe_index = 0
 for task in special_tasks:
  if task.queue_entry:
   next_job_id = task.queue_entry.job.id
  elif (task.time_started is not None):
   for queue_entry in queue_entries[hqe_index:]:
    if (queue_entry.started_on is None):
     continue
    if (queue_entry.started_on < task.time_started):
     break
    next_job_id = queue_entry.job.id
  task.next_job_id = next_job_id
  if (next_job_id is not None):
   for queue_entry in queue_entries[hqe_index:]:
    if (queue_entry.job.id < next_job_id):
     break
    hqe_index += 1

def _compute_next_job_for_tasks ( queue_entries , special_tasks ) : next_job_id = None hqe_index = 0 for task in special_tasks : if task . queue_entry : next_job_id = task . queue_entry . job . id elif ( task . time_started is not None ) : for queue_entry in queue_entries [ hqe_index : ] : if ( queue_entry . started_on is None ) : continue if ( queue_entry . started_on < task . time_started ) : break next_job_id = queue_entry . job . id task . next_job_id = next_job_id if ( next_job_id is not None ) : for queue_entry in queue_entries [ hqe_index : ] : if ( queue_entry . job . id < next_job_id ) : break hqe_index += 1
for each task .