Run shell operator synchronously to eat `in_batches`

        :param in_batches: `tuple` of batches to process
199792
def run(self, in_batches):
        
        if len(in_batches) != len(self._batcmd.batch_to_file_s):
            BaseShellOperator._rm_process_input_tmpfiles(self._batcmd.batch_to_file_s)  # [todo] - Removing tmpfiles can be easily forgot. Less lifetime for tmpfile.
            raise AttributeError('len(in_batches) == %d, while %d IN_BATCH* are specified in command below:%s$ %s' %
                                 (len(in_batches), len(self._batcmd.batch_to_file_s), os.linesep, self._batcmd.sh_cmd))

        # prepare & start process (if necessary)
        BaseShellOperator._batches_to_tmpfile(self._in_record_sep, self._in_column_sep, in_batches, self._batcmd.batch_to_file_s)
        if self._process is None:
            self._process = BaseShellOperator._start_process(
                self._batcmd, self._cwd, self._env,
                non_blocking_stdout=True)

        # Begin thread to read from subprocess's stdout.
        # Without this thread, subprocess's output buffer becomes full and no one solves it.
        t_consumer = Thread(target=get_subprocess_output,
                            args=(self._process.stdout, self._batch_done_output, self._subprocess_out_str))
        t_consumer.start()

        # pass batch to subprocess
        BaseShellOperator._batch_to_stdin(self._process, self._in_record_sep, self._in_column_sep,
                                          in_batches, self._batcmd.batch_to_file_s)

        # pass batch-done indicator to subprocess
        self._process.stdin.write(self._batch_done_indicator)

        # get output from subprocess
        t_consumer.join()
        subprocess_out_str       = self._subprocess_out_str[0]
        self._subprocess_out_str = []
        out_batch = BaseShellOperator._out_str_to_batch(subprocess_out_str,
                                                        self._out_recdef, self._out_col_patterns)
        return out_batch
774183
def loadBatch(self, records):
        
        try:
            curr_batch = records[:self.batchSize()]
            next_batch = records[self.batchSize():]
            
            curr_records = list(curr_batch)
            if self._preloadColumns:
                for record in curr_records:
                    record.recordValues(self._preloadColumns)
            
            if len(curr_records) == self.batchSize():
                self.loadedRecords[object, object].emit(curr_records,
                                                        next_batch)
            else:
                self.loadedRecords[object].emit(curr_records)
        
        except ConnectionLostError:
            self.connectionLost.emit()
        
        except Interruption:
            pass
194918
async def batch_call_api(container, apis, timeout = 120.0):
    
    apiHandles = [(object(), api) for api in apis]
    apiEvents = [ModuleAPICall(handle, targetname, name, params = params)
                 for handle, (targetname, name, params) in apiHandles]
    apiMatchers = tuple(ModuleAPIReply.createMatcher(handle) for handle, _ in apiHandles)
    async def process():
        for e in apiEvents:
            await container.wait_for_send(e)
    container.subroutine(process(), False)
    eventdict = {}
    async def process2():
        ms = len(apiMatchers)
        matchers = Diff_(apiMatchers)
        while ms:
            ev, m = await matchers
            matchers = Diff_(matchers, remove=(m,))
            eventdict[ev.handle] = ev
    await container.execute_with_timeout(timeout, process2())
    for e in apiEvents:
        if e.handle not in eventdict:
            e.canignore = True
            container.scheduler.ignore(ModuleAPICall.createMatcher(e.handle))
    return [eventdict.get(handle, None) for handle, _ in apiHandles]
942069
def i_batch(items, size):
    
    for items_batch in iter(lambda: tuple(islice(items, size)),
                            tuple()):
        yield items_batch
858187
void doBatchEnd(String batch, Object args) {
    checkOpen();
    JsonObject message = createMessage(args)
        .putString("action", "endBatch")
        .putString("batch", batch);
    if (open && !paused) {
      if (log.isDebugEnabled()) {
        log.debug(String.format("%s - Batch end: Batch[batch=%s, args=%s]", this, batch, args));
      }
      eventBus.send(inAddress, message);
    }
    if (currentBatch != null && currentBatch.id().equals(batch)) {
      currentBatch = null;
    }
  }
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)
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
151975
def run(*tasks: Awaitable, loop: asyncio.AbstractEventLoop=asyncio.get_event_loop()):
    
    futures = [asyncio.ensure_future(task, loop=loop) for task in tasks]
    return loop.run_until_complete(asyncio.gather(*futures))
260799
def _in_batches_cmdidx(cmd_array):
        
        in_batches_cmdidx_dict = {}
        for cmdidx, tok in enumerate(cmd_array):
            mat = BatchCommand.in_batches_pat.match(tok)
            if mat:
                batch_idx = int(mat.group(1))
                if batch_idx in in_batches_cmdidx_dict:
                    raise IndexError(
                        'IN_BATCH%d is used multiple times in command below, while IN_BATCH0 - IN_BATCH%d must be used:%s$ %s' %
                        (batch_idx, len(in_batches_cmdidx_dict) - 1, os.linesep, list2cmdline(cmd_array)))
                in_batches_cmdidx_dict[batch_idx] = cmdidx

        in_batches_cmdidx = []
        for batch_idx in range(len(in_batches_cmdidx_dict)):
            try:
                cmdidx = in_batches_cmdidx_dict[batch_idx]
                in_batches_cmdidx.append(cmdidx)
            except KeyError:
                raise IndexError('IN_BATCH%d is not found in command below, while IN_BATCH0 - IN_BATCH%d must be used:%s$ %s' %
                                 (batch_idx, len(in_batches_cmdidx_dict) - 1, os.linesep, list2cmdline(cmd_array)))

        return tuple(in_batches_cmdidx)
760788
function batch(ops, testCacheEnabled) {
  const cacheEnabled = testCacheEnabled || CACHE_ENABLED;

  return postgres.batch(ops)
    .then((res) => {
      if (cacheEnabled) {
        return redis.batch(ops).then(() => res);
      }

      return res;
    });
}
1109596
def batch(self, methods):
        
        methods = list(methods) # methods can be iterator
        if not methods:
            #accepts also empty list (or generator) - it allows call batch directly with query result (eventually empty)
            return
        queries, callbacks = list(zip(*[m(batch=True) for m in methods]))
        # perform all the operations in one batch
        responses = self.execute("", "POST", requests=queries)
        # perform the callbacks with the response data (updating the existing
        # objets, etc)

        batched_errors = []
        for callback, response in zip(callbacks, responses):
            if "success" in response:
                callback(response["success"])
            else:
                batched_errors.append(response["error"])

        if batched_errors:
            raise core.ParseBatchError(batched_errors)
400242
def run(self):
        '''  '''

        # find hosts that match the pattern
        hosts = self.inventory.list_hosts(self.pattern)
        if len(hosts) == 0:
            self.callbacks.on_no_hosts()
            return dict(contacted={}, dark={})

        global multiprocessing_runner
        multiprocessing_runner = self
        results = None

        # Check if this is an action plugin. Some of them are designed
        # to be ran once per group of hosts. Example module: pause,
        # run once per hostgroup, rather than pausing once per each
        # host.
        p = utils.plugins.action_loader.get(self.module_name, self)
        if p and getattr(p, 'BYPASS_HOST_LOOP', None):
            # Expose the current hostgroup to the bypassing plugins
            self.host_set = hosts
            # We aren't iterating over all the hosts in this
            # group. So, just pick the first host in our group to
            # construct the conn object with.
            result_data = self._executor(hosts[0]).result
            # Create a ResultData item for each host in this group
            # using the returned result. If we didn't do this we would
            # get false reports of dark hosts.
            results = [ ReturnData(host=h, result=result_data, comm_ok=True) \
                           for h in hosts ]
            del self.host_set
        elif self.forks > 1:
            try:
                results = self._parallel_exec(hosts)
            except IOError, ie:
                print ie.errno
                if ie.errno == 32:
                    # broken pipe from Ctrl+C
                    raise errors.AnsibleError("interupted")
                raise
        else:
            results = [ self._executor(h) for h in hosts ]
        return self._partition_results(results)
1372451
public function dispatchBatchesIfNeeded() {
        foreach(static::$batchClasses as $batch => $batchClass) {
            if ($this->status($batch)) {
                $lastRun = $this->lastRun($batch);

                if ((time() - $lastRun) > 60) {
                    $this->setLastRun($batch, time());

                    /** @var BackgroundProcess $process */
                    $process = new $batchClass();
                    $process->dispatch();
                }
            }
        }
    }
84584
private void executeBatch(BatchStatement batchState) {
        if (batchState.size() > 0) {
            m_logger.debug("Executing synchronous batch with {} statements", batchState.size());
            m_dbservice.getSession().execute(batchState);
        }
    }
358208
def run(self, records):
        
        self_name = type(self).__name__
        for i, batch in enumerate(grouper(records, self.BATCH_SIZE, skip_missing=True), 1):
            self.logger.info('%s processing batch %d', self_name, i)
            try:
                for j, proc_batch in enumerate(grouper(
                        process_records(batch).iteritems(), self.BATCH_SIZE, skip_missing=True), 1):
                    self.logger.info('%s uploading chunk #%d (batch %d)', self_name, j, i)
                    self.upload_records({k: v for k, v in proc_batch}, from_queue=True)
            except Exception:
                self.logger.exception('%s could not upload batch', self_name)
                return
            self.logger.info('%s finished batch %d', self_name, i)
            self.processed_records(batch)
        self.logger.info('%s finished', self_name)
1118171
def run_shell(args: dict) -> int:
    """"""

    if args.get('project_directory'):
        return run_batch(args)

    shell = CauldronShell()

    if in_project_directory():
        shell.cmdqueue.append('open "{}"'.format(os.path.realpath(os.curdir)))

    shell.cmdloop()
    return 0
1148842
def async_fetch_in_batch(handles, batch_size = 1000, &block)
      raise "No block given for the batch fetch request!" unless block_given?
      # Can't get data from an unfinished query
      unless async_is_complete?(handles)
        raise "Can't perform fetch on a query in state: #{async_state(handles)}"
      end

      # Now let's iterate over the results
      loop do
        rows = fetch_rows(prepare_operation_handle(handles), :next, batch_size)
        break if rows.empty?
        yield rows
      end
    end