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

Uncaught RuntimeException: you should extend the \Jenner\SimpleFork\Process and overwrite the run method #10

Open
shtse8 opened this issue Mar 29, 2017 · 6 comments · May be fixed by #14

Comments

@shtse8
Copy link

shtse8 commented Mar 29, 2017

According to the example:

$pool = new \Jenner\SimpleFork\FixedPool(2);
$pool->execute(new \Jenner\SimpleFork\Process(new TestRunnable()));
$pool->execute(new \Jenner\SimpleFork\Process(new TestRunnable()));
$pool->execute(new \Jenner\SimpleFork\Process(new TestRunnable()));

$pool->wait();

Code:

use \Jenner\SimpleFork\Pool;
use \Jenner\SimpleFork\FixedPool;
use \Jenner\SimpleFork\ParallelPool;
use \Jenner\SimpleFork\Process;
use \Jenner\SimpleFork\Runnable;

class TestRunnable implements Runnable 
{
	private $id = 0;

	public function __construct($id) {
		$this->id = $id;
	}
	
    public function run()
    {
		echo "[".$this->id."]\n";
		sleep(1);
    }
	
}

$pool = new FixedPool(2);
$pool->execute(new Process(new TestRunnable(1)));
$pool->execute(new Process(new TestRunnable(2)));
$pool->execute(new Process(new TestRunnable(3)));
$pool->wait();

Result:

PHP Fatal error:  Uncaught RuntimeException: you should extend the `\Jenner\SimpleFork\Process` and overwrite the run method in /var/www/site/www/core/vendor/jenner/simple_fork/src/Utils.php:31
Stack trace:
#0 /var/www/site/www/core/vendor/jenner/simple_fork/src/FixedPool.php(34): Jenner\SimpleFork\Utils::checkOverwriteRunMethod('Jenner\\SimpleFo...')
#1 /var/workspace/test_curl.php(31): Jenner\SimpleFork\FixedPool->execute(Object(Jenner\SimpleFork\Process))
#2 {main}
  thrown in /var/www/site/www/core/vendor/jenner/simple_fork/src/Utils.php on line 31
@shtse8
Copy link
Author

shtse8 commented Mar 29, 2017

But it works with new Pool(), I assume they are the same but with different pool type.

@white-poto
Copy link
Owner

It looks like a logical mistake, I will check it these days.

@shtse8
Copy link
Author

shtse8 commented Apr 2, 2017

I need to use FixedPool but it seems it is not working properly.

@shtse8
Copy link
Author

shtse8 commented Apr 19, 2017

any news on this?

@white-poto
Copy link
Owner

I am too busy recently, will check it after 5.1.

@rainlay
Copy link

rainlay commented May 9, 2017

I got the same problem here.

I think the point is

function checkOverwriteRunMethod

@lots0logs lots0logs linked a pull request Nov 22, 2017 that will close this issue
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

Successfully merging a pull request may close this issue.

3 participants