Method to be executed in batch mode for collecting the required fragment (composite)
        and then other custom tasks.
        :return:
760317
def batch_work(self):
        

        while True:
            gen = collect_fragment(self._stop_event, self.config['AGORA'])
            for collector, (t, s, p, o) in gen:
                for task in _batch_tasks:
                    task(collector, (t, s, p, o), self._stop_event)
                if self._stop_event.isSet():
                    return
            for task in _batch_tasks:
                task(None, None, self._stop_event)
            time.sleep(10)
1161382
function ( fragment ) {
  		if ( !batch ) return;

  		var b = batch;
  		while ( b.previousBatch ) {
  			b = b.previousBatch;
  		}

  		addToArray( b.fragments, fragment );
  	}
2827
def get_batches(qp_pairs, batch_size, need_sort=True):
    '''
    
    '''
    if need_sort:
        qp_pairs = sorted(qp_pairs, key=lambda qp: (
            len(qp['passage_tokens']), qp['id']), reverse=True)
    batches = [{'qp_pairs': qp_pairs[i:(i + batch_size)]}
               for i in range(0, len(qp_pairs), batch_size)]
    shuffle(batches)
    return batches
319250
def _create_batches(self, instances: Iterable[Instance], shuffle: bool) -> Iterable[Batch]:
        
        raise NotImplementedError
1158245
def chain_tasks(tasks):
    
    # If given tasks list is not empty
    if tasks:
        # Previous task
        previous_task = None

        # For given tasks list's each task
        for task in tasks:
            # If the task is not None.
            # Task can be None to allow code like ``task if _PY2 else None``.
            if task is not None:
                # If previous task is not None
                if previous_task is not None:
                    # Set the task to run after the previous task
                    task.set_run_after(previous_task)

                # Set the task as previous task for the next task
                previous_task = task

    # Return given tasks list.
    return tasks
588847
private CompletableFuture<Iterator<T>> batch() {
    return batch.thenCompose(iterator -> {
      if (iterator != null && !iterator.hasNext()) {
        batch = fetch(iterator.position());
        return batch.thenApply(Function.identity());
      }
      return CompletableFuture.completedFuture(iterator);
    });
  }
1305809
function defineProcessBatchTask() {
    const taskDef = TaskDef.defineTask(processBatch.name, processBatch, batchAndCancellableSettings);
    taskDef.defineSubTask(executeAllProcessOneTasks.name, executeAllProcessOneTasks, batchAndCancellableSettings);
    taskDef.defineSubTask(executeAllProcessAllTasks.name, executeAllProcessAllTasks, batchAndCancellableSettings);
    taskDef.defineSubTask(discardUnusableRecords.name, discardUnusableRecords, batchAndUnusableRecordsSettings);
    taskDef.defineSubTask(preFinaliseBatch.name, preFinaliseBatch, batchSettings);
    return taskDef;
  }
1220026
def get_batch(self):
        
        context = self.context
        parent = api.get_parent(context)
        if context.portal_type == "Batch":
            return context
        elif parent.portal_type == "Batch":
            return parent
        return None
1001565
def get_swagger_fragment(cls):
        ''''''
        if cls.__swagger_fragment:
            return cls.__swagger_fragment
        cls.__swagger_fragment = {
            'path': cls.endpoint_path.replace('<', '{').replace('>', '}'),
            'description': cls.description,
            'operations': cls.get_resource_operations(),
        }
        return cls.__swagger_fragment
1156866
def n_executions(self):
        
        pipeline = self.tiger.connection.pipeline()
        pipeline.exists(self.tiger._key('task', self.id))
        pipeline.llen(self.tiger._key('task', self.id, 'executions'))
        exists, n_executions = pipeline.execute()
        if not exists:
            raise TaskNotFound('Task {} not found.'.format(
                self.id
            ))
        return n_executions
699640
def execute(self):
        
        func_params = []
        exec_str = self.func.__name__ + '(' 
        for p in self.params:
            if p[0][0:2] != '__':   # ignore custom param names
                exec_str += p[0] + '="' + self._force_str(p[1]) + '", '
                func_params.append(p[1])
        exec_str = exec_str[:-2]
        exec_str += ')  # task' + str(self.task_id) + ': ' + self.name
        
        
        self.result = self.func(*func_params)
        print(exec_str + ' loaded ', self.result)
656922
public void executeBatch(BatchOperation batchOperation) throws FMSException {

        IntuitMessage intuitMessage = prepareBatch(batchOperation);

        //execute interceptors
        executeInterceptors(intuitMessage);

        IntuitResponse intuitResponse = (IntuitResponse) intuitMessage.getResponseElements().getResponse();
        if (intuitResponse != null) {
            List<BatchItemResponse> batchItemResponses = intuitResponse.getBatchItemResponse();
            if (batchItemResponses != null && !batchItemResponses.isEmpty()) {
                int count = 0;
                Iterator<BatchItemResponse> itr = batchItemResponses.iterator();
                while (itr.hasNext()) {
                    BatchItemResponse batchItemResponse = itr.next();
                    String bId = batchItemResponse.getBId();
                    if (!StringUtils.hasText(bId)) {
                        bId = batchOperation.getBatchItemRequests().get(count).getBId();
                    }
                    if (batchItemResponse.getFault() != null) {
                        // segregate fault batch items
                        batchOperation.getFaultResult().put(bId, batchItemResponse.getFault());
                    } else if (batchItemResponse.getReport() != null) {
                        // segregate report batch items
                        batchOperation.getReportResult().put(bId, batchItemResponse.getReport());
                    } else if (batchItemResponse.getIntuitObject() != null) {
                        // segregate entity batch items
                        batchOperation.getEntityResult().put(bId, (IEntity) batchItemResponse.getIntuitObject().getValue());
                    } else if (batchItemResponse.getQueryResponse() != null) {
                        // segregate query batch items
                        QueryResult queryResult = getQueryResult(batchItemResponse.getQueryResponse());
                        batchOperation.getQueryResult().put(bId, queryResult);
                    } else if (batchItemResponse.getCDCResponse() != null) {
                        // segregate cdc query batch items
                        CDCQueryResult cdcQueryResult = getCDCQueryResult(batchItemResponse.getCDCResponse());
                        batchOperation.getCDCQueryResult().put(bId, cdcQueryResult);
                    } else {
                        LOG.warn("BatchItemResponse is not Fault, Entity, Query and Report.");
                    }
                    count++;
                }
            }
        }
    }
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
1162378
def batch!(operations, request_options = {})
      res = batch(operations, request_options)
      res['taskID'].each do |index, taskID|
        wait_task(index, taskID, WAIT_TASK_DEFAULT_TIME_BEFORE_RETRY, request_options)
      end
    end
1252821
def create_tasks(self):
        
        roles = self.get_roles()

        if self.task_type in ["A", "D"]:
            instances = self.create_wf_instances(roles=roles)
            self.create_task_invitation(instances)

        elif self.task_type in ["C", "B"]:
            instances = self.create_wf_instances()
            self.create_task_invitation(instances, roles)
982039
def tasks(self, **kwargs):
        
        tasks_result = self.service.tasks().list(**kwargs).execute()
        return [Task(task) for task in tasks_result.get("items", [])]
393633
private int executeBatch() {
		try {
			return Arrays.stream(agent().batch(context())).sum();
		} catch (Exception ex) {
			errorAction.accept(agent(), context(), ex);
		} finally {
			batchAction.accept(agent(), context());
		}
		return 0;
	}