-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
max_wait_time
setting for the process pool to forcibly terminat…
…e worker processes after they time out.
- Loading branch information
Showing
11 changed files
with
171 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
--TEST-- | ||
swoole_process_pool: max wait time | ||
--SKIPIF-- | ||
<?php require __DIR__ . '/../include/skipif.inc'; | ||
?> | ||
--FILE-- | ||
<?php | ||
require __DIR__ . '/../include/bootstrap.php'; | ||
|
||
use Swoole\Atomic; | ||
use Swoole\Constant; | ||
use Swoole\Process\Pool; | ||
use Swoole\Timer; | ||
|
||
(function () { | ||
$atomic = new Atomic(); | ||
$pool = new Pool(4, SWOOLE_IPC_NONE); | ||
$pool->set([ | ||
Constant::OPTION_ENABLE_COROUTINE => true, | ||
Constant::OPTION_MAX_WAIT_TIME => 1, | ||
]); | ||
|
||
$pool->on('workerStart', function (Pool $pool, int $workerId) use ($atomic): void { | ||
echo "workerStart: $workerId" . PHP_EOL; | ||
$atomic->wait(-1); | ||
}); | ||
|
||
$pool->on('start', function () use ($pool): void { | ||
Timer::after(500, function () use ($pool): void { | ||
$pool->shutdown(); | ||
}); | ||
echo 'start' . PHP_EOL; | ||
}); | ||
|
||
$pool->on('shutdown', function () use ($atomic): void { | ||
echo 'shutdown' . PHP_EOL; | ||
}); | ||
|
||
$pool->start(); | ||
})(); | ||
?> | ||
--EXPECTF-- | ||
start | ||
workerStart: %d | ||
workerStart: %d | ||
workerStart: %d | ||
workerStart: %d | ||
shutdown |