This dfs checks why tasks are still pending.
544080
def _depth_first_search(set_tasks, current_task, visited):
    
    visited.add(current_task)
    if current_task in set_tasks["still_pending_not_ext"]:
        upstream_failure = False
        upstream_missing_dependency = False
        upstream_run_by_other_worker = False
        upstream_scheduling_error = False
        for task in current_task._requires():
            if task not in visited:
                _depth_first_search(set_tasks, task, visited)
            if task in set_tasks["ever_failed"] or task in set_tasks["upstream_failure"]:
                set_tasks["upstream_failure"].add(current_task)
                upstream_failure = True
            if task in set_tasks["still_pending_ext"] or task in set_tasks["upstream_missing_dependency"]:
                set_tasks["upstream_missing_dependency"].add(current_task)
                upstream_missing_dependency = True
            if task in set_tasks["run_by_other_worker"] or task in set_tasks["upstream_run_by_other_worker"]:
                set_tasks["upstream_run_by_other_worker"].add(current_task)
                upstream_run_by_other_worker = True
            if task in set_tasks["scheduling_error"]:
                set_tasks["upstream_scheduling_error"].add(current_task)
                upstream_scheduling_error = True
        if not upstream_failure and not upstream_missing_dependency and \
                not upstream_run_by_other_worker and not upstream_scheduling_error and \
                current_task not in set_tasks["run_by_other_worker"]:
            set_tasks["not_run"].add(current_task)
642058
def is_ready(instance, pending=False):
    

    last_reload = lookup(instance, 'lastOperatingSystemReload', 'id')
    active_transaction = lookup(instance, 'activeTransaction', 'id')

    reloading = all((
        active_transaction,
        last_reload,
        last_reload == active_transaction,
    ))
    outstanding = False
    if pending:
        outstanding = active_transaction
    if instance.get('provisionDate') and not reloading and not outstanding:
        return True
    return False
1012923
def is_pending(self):
        
        self.get_info()

        if 'status' not in self.info:
            return False
        if 'isPending' not in self.info['status']:
            return False

        return self.info['status']['isPending']
569087
def wait_for_compactions(self, timeout=120):
        
        pattern = re.compile("pending tasks: 0")
        start = time.time()
        while time.time() - start < timeout:
            output, err, rc = self.nodetool("compactionstats")
            if pattern.search(output):
                return
            time.sleep(1)
        raise TimeoutError("{} [{}] Compactions did not finish in {} seconds".format(time.strftime("%d %b %Y %H:%M:%S", time.gmtime()), self.name, timeout))
533242
def StartAndWait(self):
        """"""
        self.StartTask()
        self.WaitUntilTaskDone(pydaq.DAQmx_Val_WaitInfinitely)
        self.ClearTask()
552291
async def cancel_remaining(self):
        ''''''
        self._closed = True
        task_list = list(self._pending)
        for task in task_list:
            task.cancel()
        for task in task_list:
            with suppress(CancelledError):
                await task
849300
function CheckPendingThreadRequests() {
    while (PendingThreadRequests.length) {
        var tq = PendingThreadRequests.shift();
        if (!SendThreadRequest(tq)) {
            // No available thread, we queue the request, again
            PendingThreadRequests.unshift(tq);
            break;
        }
    }
}
448452
def refresh_if_needed(self):
        
        if self.state in (self.PENDING, self.STARTED):
            try:
                response, = self._fetch_result()['tasks']
            except (KeyError, ValueError):
                raise Exception(
                    "Unable to find results for task."
                )

            if 'error' in response:
                self.state == self.FAILURE
                raise ServerError(response['error'])

            if 'state' in response:
                self.state = response['state']
                self.result = response['result']
73591
function() {

		var time = new Date().getTime(),
			i = 0,
			count = this._active_tasks.length,
			task,
			active_tasks = [];

		for (; i < count; i++) {

			task = this._active_tasks[i];

			if (task.isRunning()) {
				task.onTimer(time);
				// note: at this moment task may be already off, but it's not checked - to save processor resources.
				active_tasks.push(task);
			}

		}

		if (!active_tasks.length) {

			this.is_running = false;

		}

		this._active_tasks = active_tasks;

	}
120479
def wait_for_tasks(self):
        
        finished_tasks_and_results = []
        while len(finished_tasks_and_results) == 0:
            if self.is_done():
                break
            self.start_tasks()
            self.process_all_messages_in_queue()
            finished_tasks_and_results = self.get_finished_results()
        return finished_tasks_and_results
89449
public static void waitFinished(Collection<? extends Task<?,?>> tasks) throws Exception {
		for (Task<?,?> t : tasks) {
			t.getOutput().blockThrow(0);
		}
	}
1130016
def check_for_stalled_tasks():
    
    from api.models.tasks import Task
    for task in Task.objects.filter(status_is_running=True):
        if not task.is_responsive():
            task.system_error()
        if task.is_timed_out():
            task.timeout_error()
1051688
def todo_tasks(self):
        """"""
        tasks = [task for task in self.all_tasks if task._state == NewTask._PENDING]
        return tasks
206335
def CheckTaskToMerge(self, task):
    
    with self._lock:
      is_abandoned = task.identifier in self._tasks_abandoned
      is_processing = task.identifier in self._tasks_processing
      is_queued = task.identifier in self._tasks_queued

      if not is_queued and not is_processing and not is_abandoned:
        raise KeyError('Status of task {0:s} is unknown.'.format(
            task.identifier))

      return is_queued or is_processing or is_abandoned and not task.has_retry
403117
function resolveWhen() {
          var dfd = pendings[handle];
          if (dfd) {
            dfd.forEach(function (promise) {
              promise.resolve(instance);
            });
            delete pendings[handle];
          }
        }
1262041
function Pending(runner) {

  runner.on('start', function(){
    console.log('* ')
    console.log('*********************');
    console.log('*** Pending tests ***');
    console.log('*********************');
    console.log('* ')
  });

  var scope = [];

  runner.on('pending', function(test){
    var current = [test]
      , parent = test.parent
    ;
    // stack suites
    while( !!parent ){
      current.unshift(parent)
      parent = parent.parent;
    }
    // print titles
    current.forEach(function(val, key){
      if( val != scope[key] ){
        while( scope.length > key ){
          scope.pop()
        }
        console.log( '* ' + Array(key).join('  ') + val.title );
        scope.push(val);
      }
    })
  })
}
985413
def CheckForQuestionPending(task):
    

    vm = task.info.entity
    if vm is not None and isinstance(vm, vim.VirtualMachine):
        qst = vm.runtime.question
        if qst is not None:
            raise TaskBlocked("Task blocked, User Intervention required")