当前位置: 首页>>代码示例>>PHP>>正文


PHP Job::pop_type方法代码示例

本文整理汇总了PHP中Job::pop_type方法的典型用法代码示例。如果您正苦于以下问题:PHP Job::pop_type方法的具体用法?PHP Job::pop_type怎么用?PHP Job::pop_type使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Job的用法示例。


在下文中一共展示了Job::pop_type方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: execute

	public function execute() {
		global $wgTitle;
		if ( $this->hasOption( 'procs' ) ) {
			$procs = intval( $this->getOption( 'procs' ) );
			if ( $procs < 1 || $procs > 1000 ) {
				$this->error( "Invalid argument to --procs", true );
			}
			$fc = new ForkController( $procs );
			if ( $fc->start() != 'child' ) {
				exit( 0 );
			}
		}
		$maxJobs = $this->getOption( 'maxjobs', false );
		$maxTime = $this->getOption( 'maxtime', false );
		$startTime = time();
		$type = $this->getOption( 'type', false );
		$wgTitle = Title::newFromText( 'RunJobs.php' );
		$dbw = wfGetDB( DB_MASTER );
		$n = 0;
		$conds = '';
		if ( $type !== false ) {
			$conds = "job_cmd = " . $dbw->addQuotes( $type );
		}

		while ( $dbw->selectField( 'job', 'job_id', $conds, 'runJobs.php' ) ) {
			$offset = 0;
			for ( ; ; ) {
				$job = !$type ? Job::pop( $offset ) : Job::pop_type( $type );

				if ( !$job ) {
					break;
				}

				wfWaitForSlaves( 5 );
				$t = microtime( true );
				$offset = $job->id;
				$status = $job->run();
				$t = microtime( true ) - $t;
				$timeMs = intval( $t * 1000 );
				if ( !$status ) {
					$this->runJobsLog( $job->toString() . " t=$timeMs error={$job->error}" );
				} else {
					$this->runJobsLog( $job->toString() . " t=$timeMs good" );
				}

				if ( $maxJobs && ++$n > $maxJobs ) {
					break 2;
				}
				if ( $maxTime && time() - $startTime > $maxTime ) {
					break 2;
				}
			}
		}
	}
开发者ID:schwarer2006,项目名称:wikia,代码行数:54,代码来源:runJobs.php

示例2: execute

 public function execute()
 {
     global $wgTitle;
     if ($this->hasOption('procs')) {
         $procs = intval($this->getOption('procs'));
         if ($procs < 1 || $procs > 1000) {
             $this->error("Invalid argument to --procs", true);
         }
         $fc = new ForkController($procs);
         if ($fc->start() != 'child') {
             exit(0);
         }
     }
     $maxJobs = $this->getOption('maxjobs', false);
     $maxTime = $this->getOption('maxtime', false);
     $startTime = time();
     $type = $this->getOption('type', false);
     $wgTitle = Title::newFromText('RunJobs.php');
     $dbw = wfGetDB(DB_MASTER);
     $n = 0;
     $conds = '';
     if ($type !== false) {
         $conds = "job_cmd = " . $dbw->addQuotes($type);
     }
     while ($dbw->selectField('job', 'job_id', $conds, 'runJobs.php')) {
         $offset = 0;
         for (;;) {
             $job = !$type ? Job::pop($offset) : Job::pop_type($type);
             if (!$job) {
                 break;
             }
             //check for similar (but not IDENTICAL (different timestamp allowed) jobs and delete them.
             $dbw->delete('job', array('job_cmd' => $job->command, 'job_title' => $job->title->getDBkey()), __METHOD__);
             wfWaitForSlaves();
             $t = microtime(true);
             $offset = $job->id;
             $status = $job->run();
             $t = microtime(true) - $t;
             $timeMs = intval($t * 1000);
             if (!$status) {
                 $this->runJobsLog($job->toString() . " t={$timeMs} error={$job->error}");
             } else {
                 $this->runJobsLog($job->toString() . " t={$timeMs} good");
             }
             if ($maxJobs && ++$n > $maxJobs) {
                 break 2;
             }
             if ($maxTime && time() - $startTime > $maxTime) {
                 break 2;
             }
         }
     }
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:53,代码来源:runJobs-removesimilar.php

示例3: execute

 /**
  * Main entry point, tak job from queue and run it
  *
  * @access public
  */
 public function execute()
 {
     global $wgUser, $wgApiRunJobsPerRequest;
     ini_set("memory_limit", -1);
     ini_set("max_execution_time", 0);
     $result = array();
     $done = 0;
     #
     # check if wiki is not readonly
     #
     if (!wfReadOnly()) {
         $params = $this->extractRequestParams();
         if (!$wgUser->isAllowed("runjob")) {
             $this->dieUsageMsg(array("cantrunjobs"));
         }
         #
         # api param has precedence
         #
         if (isset($params["max"])) {
             $max = $params["max"];
             if (is_numeric($max) && $max > 0 && $max <= 100) {
                 $this->maxJobs = $max;
             }
         } elseif (!empty($wgApiRunJobsPerRequest) && is_numeric($wgApiRunJobsPerRequest) && $wgApiRunJobsPerRequest > 0 && $wgApiRunJobsPerRequest <= 100) {
             $this->maxJobs = $wgApiRunJobsPerRequest;
         }
         foreach (range(1, $this->maxJobs) as $counter) {
             if (isset($params["type"])) {
                 $job = Job::pop_type($params["type"]);
             } else {
                 // refreshlinks2 has precedence
                 $job = Job::pop_type("refreshLinks2");
                 if (!$job) {
                     // any job
                     $job = Job::pop();
                 }
             }
             if ($job) {
                 $status = $job->run();
                 $result["job"][] = array("id" => $job->id, "type" => $job->command, "status" => $job->toString(), "error" => $job->error);
                 $done++;
             } else {
                 // there's no job in queue, finish loop, release request
                 break;
             }
         }
     }
     $this->wikiaLog(array("type" => isset($params["type"]) ? $params["type"] : "undefined", "maxJobs" => $this->maxJobs, "done" => $done));
     $result["left"] = $this->checkQueue($done);
     $this->getResult()->addValue(null, $this->getModuleName(), $result);
     $result = array();
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:57,代码来源:ApiRunJob.php

示例4: wfGetDB

    $maxJobs = 10000;
}
$type = false;
if (isset($options['type'])) {
    $type = $options['type'];
}
$wgTitle = Title::newFromText('RunJobs.php');
$dbw = wfGetDB(DB_MASTER);
$n = 0;
$conds = '';
if ($type !== false) {
    $conds = "job_cmd = " . $dbw->addQuotes($type);
}
while ($dbw->selectField('job', 'job_id', $conds, 'runJobs.php')) {
    $offset = 0;
    for (;;) {
        $job = $type == false ? Job::pop($offset) : Job::pop_type($type);
        if ($job == false) {
            break;
        }
        wfWaitForSlaves(5);
        print wfTimestamp(TS_DB) . "  " . $job->id . "  " . $job->toString() . "\n";
        $offset = $job->id;
        if (!$job->run()) {
            print wfTimestamp(TS_DB) . "  Error: {$job->error}\n";
        }
        if ($maxJobs && ++$n > $maxJobs) {
            break 2;
        }
    }
}
开发者ID:amjadtbssm,项目名称:website,代码行数:31,代码来源:runJobs.php

示例5: runTranscodeJobs

	function runTranscodeJobs(){
		$dbw = wfGetDB( DB_MASTER );
		$type = 'webVideoTranscode';		
		// Set the condition to only run the webVideoTranscode
		$conds = "job_cmd = " . $dbw->addQuotes( $type );

		while ( $dbw->selectField( 'job', 'job_id', $conds, 'runJobs.php' ) ) {
			$offset = 0;
			for ( ; ; ) {
				$job = Job::pop_type( $type );
				if ( !$job )
					break;

				wfWaitForSlaves( 5 );
				$t = microtime( true );
				$offset = $job->id;
				$status = $job->run();
				$t = microtime( true ) - $t;
				$timeMs = intval( $t * 1000 );				
			}
		}
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:22,代码来源:TestVideoTranscode.php


注:本文中的Job::pop_type方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。