Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I just answered another question that I found about multiple curl calls.</p> <p>This is all I did to run the requests.</p> <pre><code>do { $status = curl_multi_exec($mh, $running); } while ($status === CURLM_CALL_MULTI_PERFORM || $running); </code></pre> <p>Then I fetched the info I needed by looping over my array of curl handlers.</p> <pre><code>$returned = array(); foreach ($requests as $identifier =&gt; $request) { $returned[$identifier] = curl_multi_getcontent($request); curl_multi_remove_handle($mh, $request); curl_close($request); } </code></pre> <p>The above approach worked for me, however it seems like you want to add only a certain amount of sessions to the curl multi-handler. We could probably change the do-while loop above to the following:</p> <pre><code>do { $status = curl_multi_exec($mh, $running); if ($running &lt; $window) { for ($x = 0; $x &lt; $window - $running; $x++) { $index = count($site_map) + $x -1; curl_multi_add_handle($mh, $this-&gt;sessions[$index]); $site_map[(string) $this-&gt;sessions[$index]] = $index; } } } while ($status === CURLM_CALL_MULTI_PERFORM || $running); </code></pre> <p>After that we could modify the data fetch and replace your whole <code>while ($running &amp;&amp; $execrun === CURLM_OK){}</code> section with the following since it will only run once all your curl calls have been processed:</p> <pre><code>$returned = array(); foreach ($this-&gt;sessions as $identifier =&gt; $request) { $returned[$identifier] = curl_multi_getcontent($request); curl_multi_remove_handle($mh, $request); curl_close($request); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload