mirror of
https://github.com/danog/parallel.git
synced 2024-11-26 20:34:40 +01:00
Wait for pending task in shutdown
This commit is contained in:
parent
d7697ebd69
commit
2ac081575e
@ -38,13 +38,18 @@ abstract class TaskWorker implements Worker
|
||||
$this->context = $context;
|
||||
|
||||
$context = &$this->context;
|
||||
\register_shutdown_function(static function () use (&$context) {
|
||||
$pending = &$this->pending;
|
||||
\register_shutdown_function(static function () use (&$context, &$pending) {
|
||||
if ($context === null || !$context->isRunning()) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
Promise\wait(Promise\timeout(call(function () use ($context) {
|
||||
Promise\wait(Promise\timeout(call(function () use ($context, $pending) {
|
||||
if ($pending) {
|
||||
yield $pending;
|
||||
}
|
||||
|
||||
yield $context->send(0);
|
||||
return yield $context->join();
|
||||
}), self::SHUTDOWN_TIMEOUT));
|
||||
|
Loading…
Reference in New Issue
Block a user