We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
<?php require './SimpleFork.php'; $sf = new SimpleFork(2, 'my-process'); // 2代表子进程数, 'my-process'是进程的名字 $sf->master(function ($sf) { // 主进程的方法请包裹在master里 for ($i=0; $i<100; $i++) { $sf->submit('http://www.google.cn/', function ($data) { // 使用submit方法将其提交到一个空闲的进程,如果没有空闲的,系统会自动等待 echo $data; }); } $sf->wait(); })->slave(function ($url, $sf) { $sf->log('fetch %s', $url); // 使用内置的log方法,子进程的log也会被打印到主进程里 return $url; });
使用以上代码在 MacOS 上运行完成后,总会有两三个 php 进程仍然存活(只能强制 kill 掉)。但实际上任务已经完全运行完了。
The text was updated successfully, but these errors were encountered:
No branches or pull requests
使用以上代码在 MacOS 上运行完成后,总会有两三个 php 进程仍然存活(只能强制 kill 掉)。但实际上任务已经完全运行完了。
The text was updated successfully, but these errors were encountered: