Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parallel error using Task class #146

Closed
frufin opened this issue May 6, 2021 · 3 comments
Closed

Parallel error using Task class #146

frufin opened this issue May 6, 2021 · 3 comments

Comments

@frufin
Copy link

frufin commented May 6, 2021

Hi, I get an error while using a very basic task :

Spatie\Async\Output\ParallelError in /srv/data/web/vhosts/www.mydomain.com/htdocs/staging/vendor/spatie/async/src/Output/ParallelError.php:11
Stack trace:
#0 /srv/data/web/vhosts/www.mydomain.com/htdocs/staging/vendor/spatie/async/src/Process/ParallelProcess.php(126): Spatie\Async\Output\ParallelError::fromException()
#1 /srv/data/web/vhosts/www.mydomain.com/htdocs/staging/vendor/spatie/async/src/Process/ProcessCallbacks.php(54): Spatie\Async\Process\ParallelProcess->resolveErrorOutput()
#2 /srv/data/web/vhosts/www.mydomain.com/htdocs/staging/vendor/spatie/async/src/Pool.php(232): Spatie\Async\Process\ParallelProcess->triggerError()
#3 /srv/data/web/vhosts/www.mydomain.com/htdocs/staging/vendor/spatie/async/src/Pool.php(328): Spatie\Async\Pool->markAsFailed()
#4 /srv/data/web/vhosts/www.mydomain.com/htdocs/staging/vendor/spatie/async/src/Pool.php(154): Spatie\Async\Pool->Spatie\Async\{closure}()
#5 /srv/data/web/vhosts/www.mydomain.com/htdocs/staging/php/divalto_updates/async.php(64): Spatie\Async\Pool->wait()
#6 {main}Spatie\Async\Output\ParallelError in /srv/data/web/vhosts/www.mydomain.com/htdocs/staging/vendor/spatie/async/src/Output/ParallelError.php:11
... (same error for any array element)

Here is my Task definition :

use Spatie\Async\Task; 
class updateTask extends Task
{
	private $table;
	
	public function __construct($t) {
		$this->table = $t;
	}
	public function configure(){
		return;
	}
	public function run(){
		print_r($this->table);
	}
}

And the script using that class :

$table_info = [...];
$pool = Pool::create();
foreach ($table_info as $t) {
	$task = new updateTask($t);
	$pool->add($task)
	->catch(function ($exception) {
		print($exception);
	});
}
$pool->wait();

This error only occurs on a server with pcntl and posix enabled.
On my dev server without pcntl enabled, everything works, synchronously of course.

Thanks for your help !

@bileslav
Copy link

bileslav commented Jun 3, 2021

Hello, @frufin! Don't you figure out what the problem was? I think I faced the same issue. Here's mine: #151

@frufin
Copy link
Author

frufin commented Jun 4, 2021

Hi @Bileslaw, unfortunately, i can't help you ...
I got no answer from spatie (still maintained ?)
Anyway, i moved to a node.js server as javascript is natively asynchronous, and so nice to code.
I'm giving up PHP progressively but surely
Best !

@spatie-bot
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants