This method starts a task executing and returns immediately.
        Subclass should override this method, if it has an asynchronous
        way to start the task and return immediately.
760973
def start(self):
        
        if self.threadPool:
            self.threadPool.addTask(self)

            # Lets other threads have a chance to run
            time.sleep(0)
        else:
            raise TaskError("start(): nothing to start for task %s" % self)
659551
@Override
  public <T> T run(long timeout,
                   TimeUnit unit,
                   Consumer<Result<T>> task)
  {
    return delegate().run(timeout, unit, task);
  }
606135
void registerTaskStarted(Task task) {
        synchronized (m_activeTasks) {
            String mapKey = createMapKey(task.getTenant(), task.getTaskID());
            if (m_activeTasks.put(mapKey, task) != null) {
                m_logger.warn("Task {} registered as started but was already running", mapKey);
            }
        }
    }
636449
def start(self, *args, **kwargs):
        """"""

        self.queue = Queue()
        thread = Thread(target=self._threaded, args=args, kwargs=kwargs)
        thread.start()

        return Asynchronous.Result(self.queue, thread)
390461
def launch_next(self, task=None, result=None):
        
        if task:
            next_task = self.next(task)
            if next_task:
                return next_task.send(result=result)
            else:
                return self.set_status(task.status, result)
        elif len(self.tasks) > 0:
            return self.tasks[0].send(result=result)
        else:
            return Result(retcode=1, stderr="Nothing to do, empty operation !")
13998
public void start() {
    if (isActive) {
      return;
    }

    log.info("Starting up the default async job executor [{}].", getClass().getName());
    
    if (timerJobRunnable == null) {
      timerJobRunnable = new AcquireTimerJobsRunnable(this, processEngineConfiguration.getJobManager());
    }
    
    if (resetExpiredJobsRunnable == null) {
      resetExpiredJobsRunnable = new ResetExpiredJobsRunnable(this);
    }
    
    if (!isMessageQueueMode && asyncJobsDueRunnable == null) {
      asyncJobsDueRunnable = new AcquireAsyncJobsDueRunnable(this);
    }
    
    if (!isMessageQueueMode) {
      initAsyncJobExecutionThreadPool();
      startJobAcquisitionThread();
    }
    
    startTimerAcquisitionThread();
    startResetExpiredJobsThread();

    isActive = true;

    executeTemporaryJobs();
  }
273243
public synchronized void start() {
        if (future == null) {
            Runnable task = new Runnable() {
                                public void run() {
                                    try {
                                        accumulator.publish();
                                    } catch (Exception e) {
                                        handleException(e);
                                    }
                                }
                            };
            future = getExecutor().scheduleWithFixedDelay(task,
                                                          delayMillis, delayMillis,
                                                          TimeUnit.MILLISECONDS);
        }
    }
517967
public ReturnType dispatchWithTimeout(final Callable<PluginDispatcherReturnType<ReturnType>> task) throws TimeoutException, ExecutionException, InterruptedException {
        return dispatchWithTimeout(task, timeoutSeconds, DEFAULT_PLUGIN_TIMEOUT_UNIT);
    }
509609
private synchronized void runTask(Task task) {
        if (taskThread == null) {
            taskThread = new TaskThread();
        }
        taskThread.runTask(task);
    }
57766
def execute(self):
        

        with self._lock_c:
            self.count = 0
            self.numtasks = 0
            self.taskset = []
            self.results = {}
            self.totaltime = time.time()
            # Start all tasks
            for task in self.taskseq:
                self.taskset.append(task)
                self.numtasks += 1
                task.init_and_start(self)

        num_tasks = self.getNumTasks()
        # Wait on each task to clean up results
        while num_tasks > 0:

            self.check_state()

            for i in range(num_tasks):
                try:
                    try:
                        task = self.getTask(i)
                    except IndexError:
                        # A task got deleted from the set.  Jump back out
                        # to outer loop and repoll the number of tasks
                        break

                    #self.logger.debug("waiting on %s" % task)
                    res = task.wait(timeout=self.idletime)

                    #self.logger.debug("finished: %s" % task)
                    self.child_done(res, task)

                except TaskTimeout:
                    continue

                except Exception as e:
                    #self.logger.warning("Subtask propagated exception: %s" % str(e))
                    self.child_done(e, task)
                    continue

            # wait a bit and try again
            #self.ev_quit.wait(self.idletime)

            # re-get number of tasks, in case some were added or deleted
            num_tasks = self.getNumTasks()

        # Scan results for errors (exceptions) and raise the first one we find
        for key in self.results.keys():
            value = self.results[key]
            if isinstance(value, Exception):
                (count, task) = key
                self.logger.error("Child task %s terminated with exception: %s" % (
                    task.tag, str(value)))
                raise value

        # Return value of last child to complete
        return value
560058
def init_and_start(self, taskParent, override={}):
        
        tag = self.initialize(taskParent, override=override)
        self.start()

        return tag
620266
def execute(self, resource, **kw):
        
        params = kw.pop('params', {})
        json = kw.pop('json', None)
        task = self.make_request(
            TaskRunFailed,
            method='create',
            params=params,
            json=json,
            resource=resource)

        timeout = kw.pop('timeout', 5)
        wait_for_finish = kw.pop('wait_for_finish', True)
        
        return TaskOperationPoller(
            task=task, timeout=timeout,
            wait_for_finish=wait_for_finish,
            **kw)
719543
async def start_task(self, task: Task) -> None:
        ''''''

        try:
            Log.debug('task %s starting', task.name)
            before = time.time()
            task.counters['last_run'] = before

            task.running = True
            self.running_tasks.add(task)
            await task.run_task()
            Log.debug('task %s completed', task.name)

        except CancelledError:
            Log.debug('task %s cancelled', task.name)

        except Exception:
            Log.exception('unhandled exception in task %s', task.name)

        finally:
            self.running_tasks.discard(task)
            task.running = False
            task.task = None

            after = time.time()
            total = after - before
            task.counters['last_completed'] = after
            task.counters['duration'] = total
619906
void runAsync() {
        // Determine if a task is running. If so, record the fact we want to have it run again, otherwise reserve our spot.
        synchronized (this) {
            Exceptions.checkNotClosed(this.closed, this);
            if (this.running) {
                this.runAgain = true;
                return;
            }

            this.running = true;
        }

        // Execute the task.
        runInternal();
    }
472840
def CreateTaskStart(self):
    
    task_start = TaskStart()
    task_start.identifier = self.identifier
    task_start.session_identifier = self.session_identifier
    task_start.timestamp = self.start_time
    return task_start
54779
@Override
  public void runAfter(@Pin Consumer<? super Cancel> task, 
                       long delay, 
                       TimeUnit unit,
                       Result<? super Cancel> result)
  {
    Objects.requireNonNull(task);
    Objects.requireNonNull(unit);

    TimerListener listener = new TimerListener(task, null);

    // _timerMap.put(task, listener);
    
    listener.alarm().runAfter(unit.toMillis(delay));
    
    result.ok(listener);
  }
541984
public void async() {
		final Request request = data.build();
		final CallbackHandler handler = request.handler != null ? request.handler : singleton.handler;
		final boolean safe = request.safe != null ? request.safe : singleton.safe;

		// Ignore current request if already running (ignoreIfRunning)
		synchronized (activeRequests) {
			if (ignoreIfRunning && activeRequests.contains(request.tag)) {
				singleton.log(request.tag + " request already running! Ignoring...");
				return;
			}
			activeRequests.add(request.tag);
		}

		new AsyncTask<Void, Void, Void>() {
			@Override
			protected Void doInBackground(Void... params) {
				try {
					// Delay thread if specified
					if (delay > 0) {
						singleton.log("Delaying " + request.tag + " request for " + delay + "ms");
						Thread.sleep(delay);
					}

					// Execute request
					try {
						singleton.load(request);
					} catch (IOException e) {
						singleton.log("Error executing request " + request.tag + " asynchronously! " + e.getMessage(), Log.ERROR);
						handler.onLoadFailed(safe, request.callback.get());
					}
				} catch (InterruptedException e) {
					singleton.log(request.tag + " thread interrupted!");
				} finally {
					synchronized (activeRequests) {
						activeRequests.remove(request.tag);
					}
				}
				return null;
			}

			@Override
			protected void onCancelled(Void aVoid) {
				super.onCancelled(aVoid);

				// Double check to make sure this request is removed
				synchronized (activeRequests) {
					activeRequests.remove(request.tag);
				}
			}
		}.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
	}