in reply to Re: WWW::Curl pause conflict
in thread WWW::Curl pause conflict

Additional: I was wrong - using sleep instead of pause does not work. there is no difference whatsoever between:
while (1) { my $url = "http://kronometrix.org/"; $http->setopt(CURLOPT_URL, $url); my $retcode = $http->perform(); ## Get the results my $response = $http->getinfo(CURLINFO_HTTP_CODE); if ($retcode == 0) { print "Ok, Status: $response\n"; } else { print "Error, Status: $response\n"; } ### Check for end last if ++$loop == $loop_max; ### Interval pause; }
and
while (1) { my $url = "http://kronometrix.org/"; $http->setopt(CURLOPT_URL, $url); my $retcode = $http->perform(); ## Get the results my $response = $http->getinfo(CURLINFO_HTTP_CODE); if ($retcode == 0) { print "Ok, Status: $response\n"; } else { print "Error, Status: $response\n"; } ### Check for end last if ++$loop == $loop_max; ### Interval sleep; }
The code gets stuck after 2 run samples. Always 2 . not sure why. It seems to me something between WWW::Culr (libcurl) and perl regarding alarms and timers.

Replies are listed 'Best First'.
Re^3: WWW::Curl pause conflict
by Anonymous Monk on Sep 21, 2015 at 07:00 UTC
      Thanks for pointers. It seems related the way libcurl handles signal handlers within. I have played around by setting: CURLOPT_NOSIGNAL used to disable the timeouts while the name resolve takes place.
      $http->setopt(CURLOPT_NOSIGNAL, 1); while (1) { my stuff here ... ### Interval pause; }
      http://curl.haxx.se/libcurl/c/CURLOPT_NOSIGNAL.html This might not be smart if I really need to timeout, I think in for some reasons DNS calls are not functioning. I need to think.