Git Product home page Git Product logo

reactphp-blog-series's Issues

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

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();
		});
	}
}

`

file not found

Warning: require(C:\xampp\htdocs\video\video_streaming\reactphp_blog_series_master\ticks/../../vendor/autoload.php): failed to open stream: No such file or directory in C:\xampp\htdocs\video\video_streaming\reactphp_blog_series_master\ticks\all.php on line 3

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.