spatie / async

Easily run code asynchronously

Home Page:https://spatie.be/en/opensource/php

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Always returning error like issue 155 // Outputlength with async() function

nuht opened this issue · comments

commented

Hello,

For references : #155

It's still happening i like the syntax because i can change outputLength using methods on the $pool object. But it still always returning exception like issue 155 author. I tried with async await functions , it works well but i don't think it's possible to change outputLength that way.

Code returning only error is :

       $pool->add(new MyTask($urlTodos[0]), 1024 * 100)->then(function ($output) {
            // Handle success
            dump($output);die;
        })->catch(function (Throwable $exception) {
            // Handle exception
            dump('error');
        });

        $pool->wait();

Output is

error

Working code is :

$pool[] = async(new MyTask($urlTodos[0]))->then(function (array $output) {
            dump($output);die;
        });
        await($pool);

Output is error about output length exceding 10240 bytes.

I really need to increase outputlength, it seems i can't do it with my working code. What can I do please ?
Why does it always returning error when I use pool methods ? I did the same for basic test only returning rand int and it still always returning error.

Thanks for helping

Edit : I found a way to use $pool methods. Why that syntax is not written on the examples ?
->add(async( function () {
return rand(1,10);
}))

$pool
                ->add(async( function () {
                    return rand(1,10);
                }))
                ->then(function ($output) {
                    echo $output;
                })
                ->catch(function (Exception $exception){
                })
            ;

Now it's working fine but only with basic example, can't get it to work with myTask() class.

Dear contributor,

because this issue seems to be inactive for quite some time now, I've automatically closed it. If you feel this issue deserves some attention from my human colleagues feel free to reopen it.