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

Parser script timeout makes the speed per run last as long as the timeout value. #2

Open
Dustin013 opened this issue Jul 13, 2018 · 0 comments
Assignees

Comments

@Dustin013
Copy link

So I have modified the example you have given on your site. I noticed that whatever value you have the timeout set for, no matter how many items you feed into the array, the scripts execution time will be as long as the timeout is set for plus whatever you have running before or after it. I believe this is because the timer being used is simply to prevent long running scripts that timeout. Nevertheless, if I have 1000 items in the queue and a timeout of 2 seconds, everything fails. 2 seconds is like a hard limit for the execution time of the script. If I put in 1 URL to a file, like a 1kb thumbnail and put the timeout at 30, the execution time will be just over 30 seconds. I believe the function below is where the problem needs addressing. Either the timer needs to be canceled or the promise needs to be rejected or accepted? I am not sure what is the best practice as I am still new to reactPHP.

Keep up the great work, your site by far is the best on the web and your videos are top notch!

`
public function parse(array $urls = [], $timeout = 10, $concurrencyLimit = 8)

{
	$queue = $this->initQueue($concurrencyLimit);
	foreach ($urls as $url) {
		$promise = $queue($url)->then(
			function (\Psr\Http\Message\ResponseInterface $response) {
				if ($response->getStatusCode() == 200) {
					$this->parsed[] = $response->getStatusCode();
					// TODO Cancel timer or fulfill / reject promise???
				}
			},
			function (Exception $exception) use ($url) {
				$this->errors[$url] = $exception->getMessage();
			}
		);
		$this->loop->addTimer($timeout, function () use ($promise) {
			$promise->cancel();
		});
	}
}

`

@Dustin013 Dustin013 changed the title Parser script timeout makes the speed per record whatever the value is set to. Parser script timeout makes the speed per run last as long as the timeout value. Jul 13, 2018
@seregazhuk seregazhuk self-assigned this Sep 14, 2018
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

2 participants