Skip to content
Browse files

added usleep(200) to curl_multi_exec

  • Loading branch information...
1 parent 7ff8698 commit 3d6beb53719c8ced38fdc535ecfecf2e14b07bb5 @elvenpath committed Mar 29, 2014
Showing with 6 additions and 4 deletions.
  1. +6 −4 ParallelCurl.php
View
10 ParallelCurl.php
@@ -44,7 +44,7 @@ class ParallelCurl
public $multi_handle;
/**
- * @param int $in_max_requests
+ * @param int $in_max_requests
* @param array $in_options
*/
public function __construct($in_max_requests = 10, $in_options = array())
@@ -91,9 +91,9 @@ public function setOptions($in_options)
*
* @param string $url
* @param string $callback
- * @param array $curl_options
- * @param array $user_data
- * @param array $post_fields
+ * @param array $curl_options
+ * @param array $user_data
+ * @param array $post_fields
*/
public function startRequest($url, $curl_options, $callback, $user_data = array(), $post_fields = null)
{
@@ -151,6 +151,8 @@ private function checkForCompletedRequests()
// Since something's waiting, give curl a chance to process it
do {
$mrc = curl_multi_exec($this->multi_handle, $active);
+ // Sleep some milliseconds to avoid CPU usage.
+ usleep(200);
} while ($mrc == CURLM_CALL_MULTI_PERFORM);
// Now grab the information about the completed requests

0 comments on commit 3d6beb5

Please sign in to comment.
Something went wrong with that request. Please try again.