<?php function totalCount() { $pdo = PDO_MySQL::getInstance(); $params = ['where' => ['id' => ['>=' => 672600],]]; $result = $pdo->count('Crawl_Receive_Task', $params); $pdo = null; return $result; } function selectCountList() { $pdo = PDO_MySQL::getInstance(); $conditions = array( 'fields' => 'id,url,info_path', 'where' => ['id' => ['>=' => 672600],] ); $result = $pdo->getAll('Crawl_Receive_Task', $conditions); $pdo = null; return $result; } function update($data, $id) { $pdo = PDO_MySQL::getInstance(); $where = array( 'where' => array( 'id' => $id ) ); $result = $pdo->update('Crawl_Receive_Task', $where, $data); $pdo = null; return $result; } $t = totalCount(); $list = selectCountList(); $start=0; $threads = 4; while($start<$t){ if($start == $t) break; for($i=$start;$i<$start+$threads;$i++){ $pids[$i] = pcntl_fork(); if($pids[$i]) { echo $pids[$i]."parent".PHP_EOL; } else if(!$pids[$i]) { echo getmypid()."--".$pids[$i]."--child".PHP_EOL; $result = Curl::request('GET',$list[$i]['info_path']); update(['add_time'=>date('Y-m-d H:i:s'),'test'=>$list[$i]['id']],$list[$i]['id']); echo $result."-----------------".PHP_EOL; exit(); } usleep(100); } for($i=$start;$i<$start+$threads;$i++){ pcntl_waitpid($pids[$i], $status, WUNTRACED); $status = pcntl_wexitstatus($status); echo "--------$status finished--------".PHP_EOL; } $start+=$threads; }
|-php-fpm,16784
定襄網(wǎng)站建設(shè)公司創(chuàng)新互聯(lián)公司,定襄網(wǎng)站設(shè)計(jì)制作,有大型網(wǎng)站制作公司豐富經(jīng)驗(yàn)。已為定襄上1000家提供企業(yè)網(wǎng)站建設(shè)服務(wù)。企業(yè)網(wǎng)站搭建\外貿(mào)營(yíng)銷網(wǎng)站建設(shè)要多少錢,請(qǐng)找那個(gè)售后服務(wù)好的定襄做網(wǎng)站的公司定做!
| |-php-fpm,16817
| |-php-fpm,16821
| `-php-fpm,16822
| | |-php,17984 132.php
| | | |-php,17987 132.php
| | | | |-php,17992 132.php
| | | | | |-php,17994 132.php
| | | | | | `-php,18000 132.php
| | | | | `-php,17997 132.php
| | | | |-php,17995 132.php
| | | | | `-php,18001 132.php
| | | | `-php,17998 132.php
| | | |-php,17988 132.php
| | | | |-php,17993 132.php
| | | | | `-php,17999 132.php
| | | | `-php,17996 132.php
| | | |-php,17989 132.php
| | | | `-php,17990 132.php
| | | `-php,17991 132.php
| |-grep,18003 php
==============================================================
17984 1755
17987 17984
17988 17984
17989 17984
17991 17984
17992 17987
17995 17987
17998 17987
17993 17988
17996 17988
17990 17989
17994 17992
17997 17992
17999 17993
18000 17994
18001 17995
網(wǎng)頁(yè)題目:php多進(jìn)程實(shí)驗(yàn)筆記
新聞來(lái)源:http://jinyejixie.com/article34/ghhgpe.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供品牌網(wǎng)站設(shè)計(jì)、微信公眾號(hào)、網(wǎng)站維護(hù)、App設(shè)計(jì)、微信小程序、電子商務(wù)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)