list work units that have not yet completed
181642
def do_work_units(self, args):
        ''''''
        work_spec_name = self._get_work_spec_name(args)
        if args.status:
            status = args.status.upper()
            statusi = getattr(self.task_master, status, None)
            if statusi is None:
                self.stdout.write('unknown status {0!r}\n'.format(args.status))
                return
        else:
            statusi = None
        work_units = dict(self.task_master.get_work_units(
            work_spec_name, state=statusi, limit=args.limit))
        work_unit_names = sorted(work_units.keys())
        if args.limit:
            work_unit_names = work_unit_names[:args.limit]
        for k in work_unit_names:
            if args.details:
                tback = work_units[k].get('traceback', '')
                if tback:
                    tback += '\n'
                    work_units[k]['traceback'] = 'displayed below'
                self.stdout.write(
                    '{0!r}: {1}\n{2}'
                    .format(k, pprint.pformat(work_units[k], indent=4),
                            tback))
            else:
                self.stdout.write('{0}\n'.format(k))
1191037
def check_if_ready(self):
        """"""
        try:
            results = self.manager.check(self.results_id)
        except exceptions.ResultsNotReady as e:
            self._is_ready = False
            self._not_ready_exception = e
        except exceptions.ResultsExpired as e:
            self._is_ready = True
            self._expired_exception = e
        else:
            failures = self.get_failed_requests(results)
            members = self.get_new_members(results)
            self.results = self.__class__.Results(list(members), list(failures))
            self._is_ready = True
            self._not_ready_exception = None
1197158
private void checkForDeadTask(Tenant tenant, TaskRecord taskRecord) {
        Calendar lastReport = taskRecord.getTime(TaskRecord.PROP_PROGRESS_TIME);
        if (lastReport == null) {
            lastReport = taskRecord.getTime(TaskRecord.PROP_START_TIME);
            if (lastReport == null) {
                return; // corrupt/incomplete task record
            }
        }
        long minsSinceLastActivity = (System.currentTimeMillis() - lastReport.getTimeInMillis()) / (1000 * 60);
        if (isOurActiveTask(tenant, taskRecord.getTaskID())) {
            checkForHungTask(tenant, taskRecord, minsSinceLastActivity);
        } else {
            checkForAbandonedTask(tenant, taskRecord, minsSinceLastActivity);
        }
    }
865652
def complete(self, nextq=None, delay=None, depends=None):
        ''''''
        if nextq:
            logger.info('Advancing %s to %s from %s',
                self.jid, nextq, self.queue_name)
            return self.client('complete', self.jid, self.client.worker_name,
                self.queue_name, json.dumps(self.data), 'next', nextq,
                'delay', delay or 0, 'depends',
                json.dumps(depends or [])) or False
        else:
            logger.info('Completing %s', self.jid)
            return self.client('complete', self.jid, self.client.worker_name,
                self.queue_name, json.dumps(self.data)) or False
564214
def _insert_post_complete_tasks(context):
    """"""

    logging.debug("Context %s is complete.", context.id)

    # Async event handlers
    context.exec_event_handler('complete', transactional=True)

    # Insert cleanup tasks
    try:
        # TODO: If tracking results we may not want to auto cleanup and instead
        # wait until the results have been accessed.
        from furious.async import Async
        Async(_cleanup_markers, queue=CLEAN_QUEUE,
              args=[context.id, context.task_ids],
              task_args={'countdown': CLEAN_DELAY}).start()
    except:
        pass
222922
def checkForFinishedThreads(self):
        ''
        for t in self.unfinishedThreads:
            if not t.is_alive():
                t.endTime = time.process_time()
                if getattr(t, 'status', None) is None:
                    t.status = 'ended'
782484
def check_for_completion
      return unless all_work_units_complete?
      set_next_status
      outs = gather_outputs_from_work_units
      return queue_for_workers([outs]) if merging?
      if complete?
        update_attributes(:outputs => outs, :time => time_taken)
        CloudCrowd.log "Job ##{id} (#{action}) #{display_status}." unless ENV['RACK_ENV'] == 'test'
        CloudCrowd.defer { fire_callback } if callback_url
      end
      self
    end
1170051
def as_completed(jobs):
  '''  '''

  jobs = tuple(jobs)
  event = threading.Event()
  callback = lambda f, ev: event.set()
  [job.add_listener(Job.SUCCESS, callback, once=True) for job in jobs]
  [job.add_listener(Job.ERROR, callback, once=True) for job in jobs]

  while jobs:
    event.wait()
    event.clear()

    jobs, finished = split_list_by(jobs, lambda x: x.finished)
    for job in finished:
      yield job
497562
def _pending_of(self, workload):
        """"""
        pending = sum(list(scope.values()).count(False) for scope in workload.values())
        return pending
33258
private void taskComplete(
      HttpRemoteTaskRunnerWorkItem taskRunnerWorkItem,
      WorkerHolder workerHolder,
      TaskStatus taskStatus
  )
  {
    Preconditions.checkState(!Thread.holdsLock(statusLock), "Current thread must not hold statusLock.");
    Preconditions.checkNotNull(taskRunnerWorkItem, "taskRunnerWorkItem");
    Preconditions.checkNotNull(taskStatus, "taskStatus");
    if (workerHolder != null) {
      log.info(
          "Worker[%s] completed task[%s] with status[%s]",
          workerHolder.getWorker().getHost(),
          taskStatus.getId(),
          taskStatus.getStatusCode()
      );
      // Worker is done with this task
      workerHolder.setLastCompletedTaskTime(DateTimes.nowUtc());
    }

    // Notify interested parties
    taskRunnerWorkItem.setResult(taskStatus);
    TaskRunnerUtils.notifyStatusChanged(listeners, taskStatus.getId(), taskStatus);

    // Update success/failure counters, Blacklist node if there are too many failures.
    if (workerHolder != null) {
      blacklistWorkerIfNeeded(taskStatus, workerHolder);
    }

    synchronized (statusLock) {
      statusLock.notifyAll();
    }
  }
274371
@Override
  public void workerPreempted(final String id) {
    final Optional<Collection<Tasklet>> preemptedTasklets = runningWorkers.removeWorker(id);
    if (preemptedTasklets.isPresent()) {
      for (final Tasklet tasklet : preemptedTasklets.get()) {
        pendingTasklets.addFirst(tasklet);
      }
    }
  }
609402
private void checkForCompletion() {
        final String methodName = "checkForCompletion(): ";
        // mark the list complete if that was the last awaited key
        if (actualIndices.isEmpty()) {
            if (tc.isDebugEnabled())
                Tr.debug(tc, methodName + "setting state=COMPLETE");
            state = failedKeys == null
                            ? COMPLETE
                            : COMPLETE_WITH_FAILURES; // state change must be last action
        }
    }
464798
def pending_work_items(self):
        ""
        pending = self._conn.execute(
            "SELECT * FROM work_items WHERE job_id NOT IN (SELECT job_id FROM results)"
        )
        return (_row_to_work_item(p) for p in pending)
1045641
def workflow_incomplete(self):
        

        try:
            for pipe in self._workflow:
                with pipe.lock:
                    if pipe.completed:
                        pass
                    else:
                        return True
            return False

        except Exception, ex:
            self._logger.exception(
                'Could not check if workflow is incomplete, error:%s' % ex)
            raise
8291
def check_db_for_missing_notifications():
    """"""
    config = dallinger.config.get_config()
    participants = Participant.query.filter_by(status="working").all()
    reference_time = datetime.now()

    run_check(participants, config, reference_time)
927278
function() {
			var todos = todosDB.getList();

			var completedCount = 0;
			for (var i = 0, len = todos.length; i < len; i++) {
				if (todos[i].completed) {
					completedCount++;
				}
			}

			var itemsLeft = todos.length - completedCount;

			this.updateItemsLeft(itemsLeft);
			this.updateCompletedButton(completedCount);

		}
547676
def notify_batches_finished(self, statuses):
        
        with self._wait_condition:
            self._statuses = statuses
            self._wait_condition.notify()