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


PHP Job::pop方法代码示例

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


在下文中一共展示了Job::pop方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
             }
         }
     }
     $result["left"] = $this->checkQueue($done);
     $this->getResult()->addValue(null, $this->getModuleName(), $result);
     $result = array();
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:56,代码来源:ApiRunJob.php

示例4: array

<?php

$optionsWithArgs = array('maxjobs');
$wgUseNormalUser = true;
require_once 'commandLine.inc';
require_once "{$IP}/includes/JobQueue.php";
require_once "{$IP}/includes/FakeTitle.php";
if (isset($options['maxjobs'])) {
    $maxJobs = $options['maxjobs'];
} else {
    $maxJobs = 10000;
}
// Trigger errors on inappropriate use of $wgTitle
$wgTitle = new FakeTitle();
$dbw =& wfGetDB(DB_MASTER);
$n = 0;
while ($dbw->selectField('job', 'count(*)', '', 'runJobs.php')) {
    while (false != ($job = Job::pop())) {
        wfWaitForSlaves(5);
        print $job->id . "  " . $job->toString() . "\n";
        if (!$job->run()) {
            print "Error: {$job->error}\n";
        }
        if ($maxJobs && ++$n > $maxJobs) {
            break 2;
        }
    }
}
开发者ID:puring0815,项目名称:OpenKore,代码行数:28,代码来源:runJobs.php

示例5: doJobs

 /**
  * Do a job from the job queue
  */
 function doJobs()
 {
     global $wgJobRunRate;
     if ($wgJobRunRate <= 0 || wfReadOnly()) {
         return;
     }
     if ($wgJobRunRate < 1) {
         $max = mt_getrandmax();
         if (mt_rand(0, $max) > $max * $wgJobRunRate) {
             return;
         }
         $n = 1;
     } else {
         $n = intval($wgJobRunRate);
     }
     while ($n-- && false != ($job = Job::pop())) {
         $output = $job->toString() . "\n";
         $t = -wfTime();
         $success = $job->run();
         $t += wfTime();
         $t = round($t * 1000);
         if (!$success) {
             $output .= "Error: " . $job->getLastError() . ", Time: {$t} ms\n";
         } else {
             $output .= "Success, Time: {$t} ms\n";
         }
         wfDebugLog('jobqueue', $output);
     }
 }
开发者ID:puring0815,项目名称:OpenKore,代码行数:32,代码来源:Wiki.php

示例6: list

for (;;) {
    // determine the most lagged slave
    // if $lag == -1, there's no slave.
    list($host, $lag) = LBFactory::singleton()->getMainLB()->getMaxLag();
    if ($lag == -1) {
        // make sleeping time adaptive to database load.
        $runningThreads = smwfGetNumOfRunningThreads($dbw);
        $runningThreads = $runningThreads <= MAX_THREADS_CONSIDERED ? $runningThreads : MAX_THREADS_CONSIDERED;
        // wait depending on user-defined $rate and server load
        sleep(1 / $rate + $runningThreads);
    } else {
        // wait for most lagged slave to be *below* 1/$rate + 3 seconds lag time.
        wfWaitForSlaves(1 / $rate + 3);
    }
    // get next job
    $job = Job::pop();
    // is there a break signal?
    $accept_sock = @socket_accept($socket);
    if ($accept_sock !== false) {
        socket_getpeername($accept_sock, $name);
        if ($name == '127.0.0.1') {
            // only stop, if request comes from localhost.
            // TODO: is this SAVE? spoofing?
            print "\n\nStopped.";
            socket_close($accept_sock);
            break;
        }
    }
    if ($job == false || $job == NULL) {
        continue;
    }
开发者ID:seedbank,项目名称:old-repo,代码行数:31,代码来源:SMW_runJobsInBackground.php

示例7: doJobs

 /**
  * Do a job from the job queue
  */
 function doJobs()
 {
     global $wgJobLogFile, $wgJobRunRate;
     if ($wgJobRunRate <= 0) {
         return;
     }
     if ($wgJobRunRate < 1) {
         $max = mt_getrandmax();
         if (mt_rand(0, $max) > $max * $wgJobRunRate) {
             return;
         }
         $n = 1;
     } else {
         $n = intval($wgJobRunRate);
     }
     require_once 'JobQueue.php';
     while ($n-- && false != ($job = Job::pop())) {
         $output = $job->toString() . "\n";
         if (!$job->run()) {
             $output .= "Error: " . $job->getLastError() . "\n";
         }
         if ($wgJobLogFile) {
             error_log($output, 3, $wgJobLogFile);
         }
     }
 }
开发者ID:BackupTheBerlios,项目名称:blahtex,代码行数:29,代码来源:Wiki.php

示例8: doAsyncUpload

 /**
  * Helper function to perform an async upload, execute the job and fetch
  * the status
  *
  * @return array The result of action=upload&statuskey=key
  */
 private function doAsyncUpload($token, $ignoreWarnings = false, $leaveMessage = false)
 {
     $params = array('action' => 'upload', 'filename' => 'UploadFromUrlTest.png', 'url' => 'http://bits.wikimedia.org/skins-1.5/common/images/poweredby_mediawiki_88x31.png', 'asyncdownload' => 1, 'token' => $token);
     if ($ignoreWarnings) {
         $params['ignorewarnings'] = 1;
     }
     if ($leaveMessage) {
         $params['leavemessage'] = 1;
     }
     $data = $this->doApiRequest($params);
     $this->assertEquals($data[0]['upload']['result'], 'Queued');
     $this->assertTrue(isset($data[0]['upload']['statuskey']));
     $statusKey = $data[0]['upload']['statuskey'];
     $job = Job::pop();
     $this->assertEquals('UploadFromUrlJob', get_class($job));
     $status = $job->run();
     $this->assertTrue($status);
     $data = $this->doApiRequest(array('action' => 'upload', 'statuskey' => $statusKey, 'token' => $token));
     return $data;
 }
开发者ID:laiello,项目名称:media-wiki-law,代码行数:26,代码来源:UploadFromUrlTest.php

示例9: executeScript


//.........这里部分代码省略.........
                     $wgOut->addWikiMsg('maintenance-re-rce', $rec);
                 } else {
                     $rec = 0;
                 }
                 $total = $cur + $del + $rec;
                 $wgOut->addWikiMsg('maintenance-re-total', $total);
                 if (!$report) {
                     $rspec = array('rev_user' => $to->getId(), 'rev_user_text' => $to->getName());
                     $res = $dbw->update('revision', $rspec, $rcond, 'Maintenance::reassignEdits');
                     $aspec = array('ar_user' => $to->getId(), 'ar_user_text' => $to->getName());
                     $res = $dbw->update('archive', $aspec, $acond, 'Maintenance::reassignEdits');
                     if (!$wgRequest->getCheck('wpRc')) {
                         $cspec = array('rc_user' => $to->getId(), 'rc_user_text' => $to->getName());
                         $res = $dbw->update('recentchanges', $cspec, $ccond, 'Maintenance::reassignEdits');
                     }
                 }
                 $dbw->immediateCommit();
                 if ($report) {
                     $wgOut->addWikiMsg('maintenance-re-rr', wfMsg('maintenance-re-report'));
                 }
             } else {
                 $ton = $to->getName();
                 $wgOut->addWikiMsg('maintenance-re-nf', $ton);
             }
             $wgOut->addWikiMsg('maintenance-success', $type);
             break;
         case 'runJobs':
             $maxJobs = 10000;
             $dbw = wfGetDB(DB_MASTER);
             $n = 0;
             while ($dbw->selectField('job', 'count(*)', '', 'runJobs.php')) {
                 $offset = 0;
                 for (;;) {
                     $job = Job::pop($offset);
                     if ($job == false) {
                         break;
                     }
                     waitForSlaves(5);
                     $wgOut->addWikiText("* " . $job->id . "  " . $job->toString());
                     $offset = $job->id;
                     if (!$job->run()) {
                         $wgOut->addWikiText("** " . wfMsg('maintenance-error', array($job->error)));
                     }
                     if ($maxJobs && ++$n > $maxJobs) {
                         break 2;
                     }
                 }
             }
             $wgOut->addWikiMsg('maintenance-success', $type);
             break;
         case 'showJobs':
             $dbw = wfGetDB(DB_MASTER);
             $count = $dbw->selectField('job', 'count(*)', '', 'runJobs.php');
             $wgOut->addHTML($count);
             $wgOut->addWikiMsg('maintenance-success', $type);
             break;
         case 'stats':
             global $wgMemc;
             if (get_class($wgMemc) == 'FakeMemCachedClient') {
                 $wgOut->addWikiMsg('maintenance-memc-fake');
                 return;
             }
             $wgOut->addWikiText('<h2>' . wfMsg('maintenance-memc-requests') . '</h2>');
             $session = intval($wgMemc->get(wfMemcKey('stats', 'request_with_session')));
             $noSession = intval($wgMemc->get(wfMemcKey('stats', 'request_without_session')));
             $total = $session + $noSession;
开发者ID:amjadtbssm,项目名称:website,代码行数:67,代码来源:Maintenance_body.php

示例10: 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


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