Skip to content

Epicurl in a loop, limitations? #6

@reggi

Description

@reggi

I'm using epicurl to ping a page on my own site. Epicurl is running in a foreach loop where pockets is an array with a length anywhere from 100 to 800. For some reason when this code is run, it only pings anywhere from 30 to 45 times, no matter how long the array is. Is there a limit to how many curl operations can run asynchronously? I haven't seen any examples where epicurl is in a loop. Please let me know asap if you have any insight. My app needs this functionality and if I can't get it through async curl I need to start looking elsewhere.

$mc = EpiCurl::getInstance();
foreach($pockets as $pocket){
  $post = array('data'=>$pocket['id']);
  $ch = curl_init('http://mywebapp.com/local/api');
  curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
  curl_setopt($ch, CURLOPT_POST,count($post));
  curl_setopt($ch, CURLOPT_POSTFIELDS,curl_string($post));
  $mc->addCurl($ch);
}

Here's some more insight into what I'm doing (WITHOUT POST), the create_log function enters a row in the database. It's happening for each end in the loop and the request.

$pockets count = 250. So the database should have 500 rows. But it doesn't, the row count ranges from 350 - 475? Why is it so inconsistant?

public function psc(){
  $mc = EpiCurl::getInstance();
  $pockets = pockets();
  foreach($pockets as $pocket){
    $ch = curl_init('http://mysite.com/psapi');
    $mc->addCurl($ch);
    create_log(array('created_at'=>date('Y-m-d H:i:s', time()),'where'=>'psc'));
  }
}

public function psapi(){
    create_log(array(''created_at'=>date('Y-m-d H:i:s', time()),'where'=>'psapi'));
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions