Push a reindex job to the actions handler pool
339850
def push_reindex_to_actions_pool(obj, idxs=None):
    
    indexes = idxs and idxs or []
    pool = ActionHandlerPool.get_instance()
    pool.push(obj, "reindex", success=True, idxs=indexes)
1118499
def requeue_job(self, job, queue, priority, delayed_for=None):
        
        job.requeue(queue_name=queue._cached_name,
                    priority=priority,
                    delayed_for=delayed_for,
                    queue_model=self.queue_model)

        if hasattr(job, 'on_requeued'):
            job.on_requeued(queue)

        self.log(self.job_requeue_message(job, queue))
418879
private void pushToApplicationCache(int typeToProcess, int typeAfterProcess)
    {
        for(Iterator iter = sessionCache.values().iterator(); iter.hasNext();)
        {
            CacheEntry entry = (CacheEntry) iter.next();
            // if the cached object was garbage collected, nothing to do
            Object result = entry.get();
            if(result == null)
            {
                if(log.isDebugEnabled())
                    log.debug("Object in session cache was gc, nothing to push to application cache");
            }
            else
            {
                // push all objects of the specified type to application cache
                if(entry.type == typeToProcess)
                {
                    if(log.isDebugEnabled())
                    {
                        log.debug("Move obj from session cache --> application cache : " + entry.oid);
                    }
                    /*
                    arminw:
                    only cache non-proxy or real subject of materialized proxy objects
                    */
                    if(ProxyHelper.isMaterialized(result))
                    {
                        putToApplicationCache(entry.oid, ProxyHelper.getRealObject(result), false);
                        // set the new type after the object was pushed to application cache
                        entry.type = typeAfterProcess;
                    }
                }
            }
        }
    }
1261891
private void submitSlaEvent(Job job) {
    try {
      CompactionSlaEventHelper
          .getEventSubmitterBuilder(this.dataset, Optional.of(job), this.fs)
          .eventSubmitter(this.eventSubmitter)
          .eventName(CompactionSlaEventHelper.COMPACTION_COMPLETED_EVENT_NAME)
          .additionalMetadata(
              CompactionSlaEventHelper.LATE_RECORD_COUNT,
              Long.toString(this.lateOutputRecordCountProvider.getRecordCount(this.getApplicableFilePaths(this.dataset
                  .outputLatePath(), this.fs))))
          .additionalMetadata(
              CompactionSlaEventHelper.REGULAR_RECORD_COUNT,
              Long.toString(this.outputRecordCountProvider.getRecordCount(this.getApplicableFilePaths(this.dataset
                  .outputPath(), this.fs))))
          .additionalMetadata(CompactionSlaEventHelper.RECOMPATED_METADATA_NAME,
              Boolean.toString(this.dataset.needToRecompact())).build().submit();
    } catch (Throwable e) {
      LOG.warn("Failed to submit compaction completed event:" + e, e);
    }
  }
1076595
function push(jobProfileString, jobOpt /*jobOptInterface*/, namespace) {
    logger.debug(`Following litteral was pushed \n ${util.format(jobOpt)}`);
    let jobID = uuidv4();
    if (jobOpt.hasOwnProperty('id'))
        if (jobOpt.id)
            jobID = jobOpt.id;
    let workDir;
    if (namespace) {
        try {
            fs.mkdirSync(cacheDir + '/' + namespace);
        }
        catch (err) {
            if (err.code != 'EEXIST') {
                logger.error("Namespace " + cacheDir + '/' + namespace + ' already exists.');
                throw err;
            }
        }
        workDir = cacheDir + '/' + namespace + '/' + jobID;
    }
    else {
        workDir = cacheDir + '/' + jobID;
    }
    /* Building a jobOptInterface litteral out of the jobOpt function parameter */
    let jobTemplate = {
        // "engineHeader": engine.generateHeader(jobID, jobProfileString, workDir),
        "engine": engine,
        "workDir": workDir,
        "emulated": emulator ? true : false,
        "adress": TCPip,
        "port": TCPport,
        "jobProfile": jobProfileString ? jobProfileString : "default"
        // "submitBin": engine.submitBin(),
    };
    if ('exportVar' in jobOpt)
        jobTemplate.exportVar = jobOpt.exportVar;
    if ('modules' in jobOpt)
        jobTemplate.modules = jobOpt.modules;
    if ('script' in jobOpt)
        jobTemplate.script = jobOpt.script;
    if ('cmd' in jobOpt)
        jobTemplate.cmd = jobOpt.cmd;
    if ('inputs' in jobOpt)
        jobTemplate.inputs = jobOpt.inputs;
    if ('tagTask' in jobOpt)
        jobTemplate.tagTask = jobOpt.tagTask;
    if ('ttl' in jobOpt)
        jobTemplate.ttl = jobOpt.ttl;
    if ('socket' in jobOpt)
        jobTemplate.socket = jobOpt.socket;
    logger.debug(`Following jobTemplate was successfully buildt \n ${util.format(jobTemplate)}`);
    let newJob = new jobLib.jobObject(jobTemplate, jobID);
    if ('fromConsumerMS' in jobOpt)
        newJob.fromConsumerMS = jobOpt.fromConsumerMS;
    // 3 outcomes
    // newJob.launch // genuine start
    // newJob.resurrect // load from wareHouse a complete job
    // newJob.melt // replace newJob by an already running job
    //                just copying client socket if fromConsumerMS 
    //
    logger.debug(`Following jobObject was successfully buildt \n ${util.format(newJob)}`);
    newJob.start();
    liveMemory.addJob(newJob);
    newJob.on('inputSet', function () {
        // All input streams were dumped to file(s), we can safely serialize
        let jobSerial = newJob.getSerialIdentity();
        MS_lookup(jobSerial)
            .on('known', function (fStdoutName, fStderrName, workPath) {
            newJob.respawn(fStdoutName, fStderrName, workPath);
            newJob.jEmit("completed", newJob);
            // Repertoir valide
            // Extraire la sortie d'erreur / standard du job et faire lever levent completed
            //logger.info("I CAN RESURRECT YOU : " + validWorkFolder + ' -> ' + jobTemplate.tagTask);
            //_resurrect(newJob, validWorkFolder);
        })
            .on('unknown', function () {
            logger.debug("####No suitable job found in warehouse");
            let previousJobs;
            previousJobs = liveMemory.lookup(newJob);
            if (previousJobs) {
                // let refererJob:jobLib.jobObject = getJob(previousJobs[0].id];
                logger.debug(`${previousJobs.length} suitable living job(s) found, shimmering`);
                melting(previousJobs[0], newJob);
                return;
            }
            logger.debug('No Suitable living jobs found, launching');
            //liveStore(newJob.getSerialIdentity());  
            //jobRegister(newJob);
            liveMemory.jobSet('source', { jobObject: newJob });
            newJob.launch();
            newJob.on('submitted', function (j) {
                liveMemory.jobSet('SUBMITTED', { jobObject: newJob });
                //jobsArray[j.id].status = 'SUBMITTED';
            }).on('jobStart', function (job) {
                engine.list();
                // shall we call dropJob function here ?
            }).on('scriptReadError', function (err, job) {
                logger.error(`ERROR while reading the script : \n ${err}`);
            }).on('scriptWriteError', function (err, job) {
                logger.error(`ERROR while writing the coreScript : \n ${err}`);
            }).on('scriptSetPermissionError', function (err, job) {
                logger.error(`ERROR while trying to set permissions of the coreScript : \n ${err}`);
            });
        });
    });
    exhaustBool = true;
    //console.log(jobsArray);
    return newJob;
}
727957
function handleArrayResult(m, workerIdx) {
	var job = jobs[m.context.jobID],
		partition = m.context.partition,
		subResult = m.result,
		result = [],
		i;
	
	job.result[partition] = subResult;

	// Increase callback count.
	job.cbCount++;
	
	// When all workers are finished return result
	if(job.cbCount === workers.length) {
		for (i = 0; i < job.result.length; i++) {
			result = result.concat(job.result[i]);
		};
		
		// Cle
		job.cb(null, result);
	}

	// Worker is finished.
	workerJobCount[workerIdx]--;
	dispatchWorkItems();
}
565877
public function push($job, array $data = null, $queue = null)
    {
        if (false !== ($delay = \Resque::getConfig('default.jobs.delay', false))) {
            return $this->later($delay, $job, $data, $queue);
        }

        return Job::create($this->getQueue($queue), $job, $data);
    }
276448
def add_job(self, data, persist=True):
        '''
        
        '''

        # we don't do any checking here besides making sure its a dict.
        # eval() already does for us and raises errors accordingly
        if not isinstance(data, dict):
            raise ValueError('Scheduled jobs have to be of type dict.')
        if not len(data) == 1:
            raise ValueError('You can only schedule one new job at a time.')

        # if enabled is not included in the job,
        # assume job is enabled.
        for job in data:
            if 'enabled' not in data[job]:
                data[job]['enabled'] = True

        new_job = next(six.iterkeys(data))

        if new_job in self._get_schedule(include_opts=False):
            log.warning("Cannot update job %s, it's in the pillar!", new_job)

        elif new_job in self.opts['schedule']:
            log.info('Updating job settings for scheduled job: %s', new_job)
            self.opts['schedule'].update(data)

        else:
            log.info('Added new job %s to scheduler', new_job)
            self.opts['schedule'].update(data)

        # Fire the complete event back along with updated list of schedule
        evt = salt.utils.event.get_event('minion', opts=self.opts, listen=False)
        evt.fire_event({'complete': True,
                        'schedule': self._get_schedule()},
                       tag='/salt/minion/minion_schedule_add_complete')

        if persist:
            self.persist()
904290
def put(self, body, priority=DEFAULT_PRIORITY, delay=0, ttr=DEFAULT_TTR):
        """"""
        assert isinstance(body, str), 'Job body must be a str instance'
        jid = self._interact_value('put %d %d %d %d\r\n%s\r\n' % (
                                       priority, delay, ttr, len(body), body),
                                   ['INSERTED'],
                                   ['JOB_TOO_BIG', 'BURIED', 'DRAINING'])
        return int(jid)
682042
def submit_jobs(self, link, job_dict=None, job_archive=None, stream=sys.stdout):
        
        if link is None:
            return JobStatus.no_job
        if job_dict is None:
            job_keys = link.jobs.keys()
        else:
            job_keys = sorted(job_dict.keys())

        # copy & reverse the keys b/c we will be popping item off the back of
        # the list
        unsubmitted_jobs = job_keys
        unsubmitted_jobs.reverse()

        failed = False
        if unsubmitted_jobs:
            if stream != sys.stdout:
                sys.stdout.write('Submitting jobs (%i): ' %
                                 len(unsubmitted_jobs))
                sys.stdout.flush()
        while unsubmitted_jobs:
            status = get_lsf_status()
            njob_to_submit = min(self._max_jobs - status['NJOB'],
                                 self._jobs_per_cycle,
                                 len(unsubmitted_jobs))

            if self._dry_run:
                njob_to_submit = len(unsubmitted_jobs)

            for i in range(njob_to_submit):
                job_key = unsubmitted_jobs.pop()

                # job_details = job_dict[job_key]
                job_details = link.jobs[job_key]
                job_config = job_details.job_config
                if job_details.status == JobStatus.failed:
                    clean_job(job_details.logfile, {}, self._dry_run)
                    # clean_job(job_details.logfile,
                    #          job_details.outfiles, self.args['dry_run'])

                job_config['logfile'] = job_details.logfile
                new_job_details = self.dispatch_job(
                    link, job_key, job_archive, stream)
                if new_job_details.status == JobStatus.failed:
                    failed = True
                    clean_job(new_job_details.logfile,
                              new_job_details.outfiles, self._dry_run)
                link.jobs[job_key] = new_job_details

            if unsubmitted_jobs:
                if stream != sys.stdout:
                    sys.stdout.write('.')
                    sys.stdout.flush()
                stream.write('Sleeping %.0f seconds between submission cycles\n' %
                             self._time_per_cycle)
                time.sleep(self._time_per_cycle)

        if failed:
            return JobStatus.failed

        if stream != sys.stdout:
            sys.stdout.write('!\n')

        return JobStatus.done
119599
def run(self, tmp=None, task_vars=None):
        
        self._connection.on_action_run(
            task_vars=task_vars,
            delegate_to_hostname=self._task.delegate_to,
            loader_basedir=self._loader.get_basedir(),
        )
        return super(ActionModuleMixin, self).run(tmp, task_vars)
286546
def execute_job(self, job_request):
        
        # Run the Job's Actions
        job_response = JobResponse()
        job_switches = RequestSwitchSet(job_request['context']['switches'])
        for i, raw_action_request in enumerate(job_request['actions']):
            action_request = EnrichedActionRequest(
                action=raw_action_request['action'],
                body=raw_action_request.get('body', None),
                switches=job_switches,
                context=job_request['context'],
                control=job_request['control'],
                client=job_request['client'],
                async_event_loop=job_request['async_event_loop'],
                run_coroutine=job_request['run_coroutine'],
            )
            action_in_class_map = action_request.action in self.action_class_map
            if action_in_class_map or action_request.action in ('status', 'introspect'):
                # Get action to run
                if action_in_class_map:
                    action = self.action_class_map[action_request.action](self.settings)
                elif action_request.action == 'introspect':
                    from pysoa.server.action.introspection import IntrospectionAction
                    action = IntrospectionAction(server=self)
                else:
                    if not self._default_status_action_class:
                        from pysoa.server.action.status import make_default_status_action_class
                        self._default_status_action_class = make_default_status_action_class(self.__class__)
                    action = self._default_status_action_class(self.settings)
                # Wrap it in middleware
                wrapper = self.make_middleware_stack(
                    [m.action for m in self.middleware],
                    action,
                )
                # Execute the middleware stack
                try:
                    action_response = wrapper(action_request)
                except ActionError as e:
                    # Error: an error was thrown while running the Action (or Action middleware)
                    action_response = ActionResponse(
                        action=action_request.action,
                        errors=e.errors,
                    )
            else:
                # Error: Action not found.
                action_response = ActionResponse(
                    action=action_request.action,
                    errors=[Error(
                        code=ERROR_CODE_UNKNOWN,
                        message='The action "{}" was not found on this server.'.format(action_request.action),
                        field='action',
                    )],
                )

            job_response.actions.append(action_response)
            if (
                action_response.errors and
                not job_request['control'].get('continue_on_error', False)
            ):
                # Quit running Actions if an error occurred and continue_on_error is False
                break

        return job_response
68118
function executeJob (options, opType, callback) {
  var job = client.query(options.namespace, options.set, options.statement)
  var stream = job.execute()
  stream.on('data', function (record) {
    // count the records returned
    intervalData[opType][TPS]++
  })
  stream.on('error', function (error) {
    intervalData[opType][ERROR]++
    if (error.code === status.ERR_TIMEOUT) {
      intervalData[opType][TIMEOUT]++
    }
  })
  stream.on('end', function () {
    // update a stat for number of jobs completed.
    callback(options)
  })
}
302079
public function push($job, $data = '', $queue = null)
    {
        $queueJob = $this->resolveJob($this->createPayload($job, $queue, $data), $queue);

        try {
            $this->raiseBeforeJobEvent($queueJob);

            $queueJob->fire();

            $this->raiseAfterJobEvent($queueJob);
        } catch (Exception $e) {
            $this->handleException($queueJob, $e);
        } catch (Throwable $e) {
            $this->handleException($queueJob, new FatalThrowableError($e));
        }

        return 0;
    }
984773
def commit(self):
        """"""
        self.send_buffered_operations()
        retry_until_ok(self.elastic.indices.refresh, index="")
1354971
def reindex(config):
    

    request = config.task(_reindex).get_request()
    config.task(_reindex).run(request)
1244433
def _push_next(self):
        """"""
        r = next(self._iter, None)
        if r is None:
            return
        async_ret = self._worker_pool.apply_async(
            self._worker_fn, (r, self._batchify_fn, self._dataset))
        self._data_buffer[self._sent_idx] = async_ret
        self._sent_idx += 1