async
async copied to clipboard
PHP Warning: Failed to set memory limit to 0 bytes (Current memory usage is 2097152 bytes) in Unknown on line 0
Using the code from the documentation, I get the warning PHP Warning: Failed to set memory limit to 0 bytes (Current memory usage is 2097152 bytes) in Unknown on line 0
.
Code
$pool = Pool::create();
foreach (range(1, 5) as $i) {
$pool[] = async(function () use ($i) {
// Something to execute in a child process.
})->then(function (int $output) {
// Handle output returned from the child process.
})->catch(function ( $exception) {
dd($exception);
// Handle exceptions thrown in the child process.
});
}
$r = await($pool);
Stacktrace
Spatie\Async\Output\ParallelError {#1428 // app/Collections/CustomerCommentCollection.php:25
#message: "PHP Warning: Failed to set memory limit to 0 bytes (Current memory usage is 2097152 bytes) in Unknown on line 0
"
#code: 0
#file: "
/var/www/html/vendor
/spatie/async/
src/Output/ParallelError.php"
#line: 11
trace: {
/var/www/html/vendor
/spatie/async/
src/Output/ParallelError.php:11 {
Spatie\Async\Output
\
ParallelError::fromException($exception): self …
› {
› return new self($exception);
› }
}
/var/www/html/vendor
/spatie/async/
src/Process/ParallelProcess.php:125 {
Spatie\Async\Process
\
ParallelProcess->resolveErrorOutput(): Throwable …
› if (! $exception instanceof Throwable) {
› $exception = ParallelError::fromException($exception);
› }
}
/var/www/html/vendor
/spatie/async/
src/Process/ProcessCallbacks.php:54 {
Spatie\Async\Process
\
ParallelProcess->triggerError() …
› {
› $exception = $this->resolveErrorOutput();
›
}
/var/www/html/vendor
/spatie/async/
src/Process/ProcessCallbacks.php:38 {
Spatie\Async\Process
\
ParallelProcess->triggerSuccess() …
› if ($this->getErrorOutput()) {
› $this->triggerError();
›
}
/var/www/html/vendor
/spatie/async/
src/Pool.php:223 {
Spatie\Async
\
Pool->markAsFinished(Runnable $process) …
›
› $this->results[] = $process->triggerSuccess();
›
}
/var/www/html/vendor
/spatie/async/
src/Pool.php:358 {
Spatie\Async
\
Pool->handleFinishedProcess(int $pid, int $status) …
› if ($status === 0) {
› $this->markAsFinished($process);
›
}
/var/www/html/vendor
/spatie/async/
src/Pool.php:344 {
Spatie\Async\Pool->Spatie\Async
\
{closure} …
›
› $this->handleFinishedProcess($pid, $status['status']);
› }
}
/var/www/html/vendor
/spatie/async/
src/Pool.php:168 {
Spatie\Async
\
Pool->wait(?callable $intermediateCallback = null): array …
› {
› while ($this->inProgress) {
› foreach ($this->inProgress as $process) {
}
/var/www/html/vendor
/spatie/async/
src/helpers.php:22 {
await(Pool $pool): array …
› {
› return $pool->wait();
› }
}
/var/www/html
/
app/Collections/CustomerCommentCollection.php:30 {
App\Collections
\
CustomerCommentCollection->attachTextComment() …
›
› $r = await($pool);
› dd($r);
}
I have also tried this snippet
use Spatie\Async\Pool;
$pool = Pool::create();
foreach ($things as $thing) {
$pool->add(function () use ($thing) {
// Do a thing
})->then(function ($output) {
// Handle success
})->catch(function (Throwable $exception) {
// Handle exception
});
}
$pool->wait();
It gives the error sh: 1: exec: : Permission denied
.
Im using php 8.3 and the posix and pcntl extensions are both enabled.
$pool->isSupported()
returns true.
What could be the issue?