will trigger workers to cancel then wait for it to report back.
195493
@SuppressWarnings("deprecation")
    private final void operationTimeout() {

        /**
         * first kill async http worker; before suicide LESSON: MUST KILL AND
         * WAIT FOR CHILDREN to reply back before kill itself.
         */
        cancelCancellable();
        if (asyncWorker != null && !asyncWorker.isTerminated()) {
            asyncWorker
                    .tell(RequestWorkerMsgType.PROCESS_ON_TIMEOUT, getSelf());

        } else {
            logger.info("asyncWorker has been killed or uninitialized (null). "
                    + "Not send PROCESS ON TIMEOUT.\nREQ: "
                    + request.toString());
            replyErrors(PcConstants.OPERATION_TIMEOUT,
                    PcConstants.OPERATION_TIMEOUT, PcConstants.NA,
                    PcConstants.NA_INT);
        }

    }
1041498
def SignalAbort(self):
    """"""
    self._abort = True
    if self._foreman_status_wait_event:
      self._foreman_status_wait_event.set()
    if self._analysis_mediator:
      self._analysis_mediator.SignalAbort()
1264420
def cancelPendingResultsFor( self, ps ):
        """"""
        k = self._parametersAsIndex(ps)

        if k in self._results.keys():
            # remove from results
            rs = self._results[k]
            js = [ j for j in rs if not isinstance(j, dict) ]
            self._results[k] = [ rc for rc in rs if isinstance(rc, dict) ]

            # ...and from pending jobs list
            for j in js:
                del self._pending[j]
154932
@Override
    public boolean cancel(boolean mayInterruptIfRunning) {
        if (m_isDone == true) {
            return false;
        }
        m_isDone = true;

        if (m_pendingException != null) {
            return false;
        }

        m_cancelResult = m_schedFuture.cancel(false);

        if ((m_cancelResult != true) || (m_defaultFuture != null)) {
            // Push the cancel call to the Default Executor Future if it has progressed that far.
            try {
                this.m_coordinationLatch.await();
            } catch (InterruptedException ie) {
                // Try to proceed.
            }

            if (m_defaultFuture != null) {
                m_cancelResult = m_defaultFuture.cancel(mayInterruptIfRunning);
            }
        }

        if (m_cancelResult == true) {
            m_pendingException = new CancellationException();
            m_scheduledExecutorQueue.remove(this);
        }

        // Let get() finish
        this.m_coordinationLatch.countDown();

        return m_cancelResult;
    }
1047804
def _wait_trigger(self):
        """"""
        if _debug: IOQController._debug("_wait_trigger")

        # make sure we are waiting
        if (self.state != CTRL_WAITING):
            raise RuntimeError("not waiting")

        # change our state
        self.state = CTRL_IDLE
        _statelog.debug("%s %s %s" % (_strftime(), self.name, "idle"))

        # look for more to do
        IOQController._trigger(self)
984162
private void tryReactivate(WorkQueue w, WorkQueue[] ws, int r) {
        long c; int sp, wl; WorkQueue v;
        if ((sp = (int)(c = ctl)) != 0 && w != null &&
            ws != null && (wl = ws.length) > 0 &&
            ((sp ^ r) & SS_SEQ) == 0 &&
            (v = ws[(wl - 1) & sp]) != null) {
            long nc = (v.stackPred & SP_MASK) | (UC_MASK & (c + AC_UNIT));
            int ns = sp & ~UNSIGNALLED;
            if (w.scanState < 0 &&
                v.scanState == sp &&
                U.compareAndSwapLong(this, CTL, c, nc)) {
                v.scanState = ns;
                LockSupport.unpark(v.parker);
            }
        }
    }
788758
def cancelled(self):
        """"""
        self._refresh_and_update()
        return (
            self._operation.HasField("error")
            and self._operation.error.code == code_pb2.CANCELLED
        )
783076
def cancel(self, order_id):
        """"""

        response = self.request(E.cancelSslCertRequest(
            E.id(order_id)
        ))

        return int(response.data.id)
1063889
def cancelPendingResultsFor( self, params ):
        """"""
        
        # grab the result job ids
        jobs = self.pendingResultsFor(params)
        
        if len(jobs) > 0:
            # abort in the cluster
            self._abortJobs(jobs)
            
            # cancel in the notebook                  
            self.notebook().cancelPendingResultsFor(params)
448615
function handleExecResult(m, workerIdx) {
	var job = jobs[m.context.jobID];
		
	job.cb(m.err, m.result);

	// Worker is finished.
	workerJobCount[workerIdx]--;
	dispatchWorkItems();
}
763742
def _callback(self, bjobid, result, grade, problems, tests, custom, archive, stdout, stderr):
        
        self._jobs_done[str(bjobid)] = (result, grade, problems, tests, custom, archive, stdout, stderr)
        self._waiting_jobs.remove(str(bjobid))
84045
def wait_for_workers(self, min_n_workers=1):
		
	
		self.logger.debug('wait_for_workers trying to get the condition')
		with self.thread_cond:
			while (self.dispatcher.number_of_workers() < min_n_workers):
				self.logger.debug('HBMASTER: only %i worker(s) available, waiting for at least %i.'%(self.dispatcher.number_of_workers(), min_n_workers))
				self.thread_cond.wait(1)
				self.dispatcher.trigger_discover_worker()
				
		self.logger.debug('Enough workers to start this run!')
1177181
function cancel(opt_reason) {
    if (!isPending()) {
      return;
    }

    if (opt_canceller) {
      opt_reason = opt_canceller(opt_reason) || opt_reason;
    }

    reject(opt_reason);
  }
604142
def wait_for_subworkflows(self, workflow_results):
        ''''''
        wf_ids = sum([x['pending_workflows'] for x in workflow_results], [])
        for wf_id in wf_ids:
            # here we did not check if workflow ids match
            yield self.socket
            res = self.socket.recv_pyobj()
            if res is None:
                sys.exit(0)
            elif isinstance(res, Exception):
                raise res
1110528
def _wait_for_result(self):
        """"""
        basetime = 0.018 if self._low_res else 0.128
        sleep(basetime * (self._mtreg / 69.0) + self._delay)
1075741
function Stopping(worker, startedAt) {
    var spec = worker.spec;
    this.worker = worker;
    this.nextState = null;
    this.isDebugging = false;
    this.startedAt = startedAt;
    this.stopRequestedAt = Date.now();
    this.forceStopHandle = null;
    this.forceStopAt = null;
    this.forcedStop = false;
    this.forceStopDelay = spec.forceStopDelay;

    // Schedule a forceful shutdown if graceful shutdown does not complete in a
    // timely fashion.
    if (this.forceStopDelay < Infinity) {
        this.forceStopAt = Date.now() + this.forceStopDelay;
        this.forceStopHandle = setTimeout(
            this.handleForceStopTimeout.bind(this),
            this.forceStopDelay
        );
    }
}
1225044
public void cancel() {
        if(actionInBackground != null) {
            if(executorService != null) {
               asyncFutureTask.cancel(true);
            } else {
                asyncThread.interrupt();
            }
        }
    }