spatie / async

Easily run code asynchronously
https://spatie.be/en/opensource/php
MIT License
2.65k stars 179 forks source link

Not working as expected after PHP 8.2 update #214

Closed alparslanahmed closed 1 year ago

alparslanahmed commented 1 year ago

Hello,

i updated my Ubuntu system with all packages including php. After that update issue started. I am adding tasks to the pool and tasks are being completed but waiting for pool doesnt stop. It stucks at $pool->wait();

jokerisgod commented 1 year ago

Facing the same issue

tschlaeppi commented 1 year ago

Hi, I'm facing the same issue but with PHP 8.1.

php -v
PHP 8.1.22 (cli) (built: Aug 29 2023 10:30:06) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.22, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.22, Copyright (c), by Zend Technologies
    with Xdebug v3.2.1, Copyright (c) 2002-2023, by Derick Rethans

Code

<?php

$autoloader = require __DIR__ . '/vendor/autoload.php';

use Spatie\Async\Pool;

$pool = Pool::create();

foreach (range(1, 5) as $i) {
    $pool[] = async(function () use ($i) {
       $output = $i * 2;
       return $output;
    })->then(function (int $output) {
       echo $output . "\n";
    });
}
await($pool);

Result

4
2
8
10

...and hanging infinitely.

One Job seems to be blocking or the results didn't find the way back... Every now and then, the code will be executed with success.

tschlaeppi commented 1 year ago

Seems to be resolved with PHP 8.1.23

PHP 8.1.23 (cli) (built: Sep  2 2023 06:59:15) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.23, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.23, Copyright (c), by Zend Technologies
    with Xdebug v3.2.1, Copyright (c) 2002-2023, by Derick Rethans

@alparslanahmed , @jokerisgod : With 8.2, version 8.2.10 was released a few days ago. Might be resolved as well for you.

jokerisgod commented 1 year ago

@tschlaeppi yep just upgraded to 8.2.10 and it was resolved. thanks mate!

alparslanahmed commented 1 year ago

After upgrading package to the last version issue solved!