diff options
author | Urban Müller | 2020-04-21 14:45:33 +0200 |
---|---|---|
committer | Urban Müller | 2020-04-21 14:45:33 +0200 |
commit | 8b65a2b2426fd04d46c943c76af40347a611bcee (patch) | |
tree | f61aa5e9fbad5cd07184932418c616e859e983a6 /it_url.class | |
parent | d987adefc85095f057c3d6d3eb2fa4c0d487d32b (diff) | |
download | itools-8b65a2b2426fd04d46c943c76af40347a611bcee.tar.gz itools-8b65a2b2426fd04d46c943c76af40347a611bcee.tar.bz2 itools-8b65a2b2426fd04d46c943c76af40347a611bcee.zip |
support retrysleep in ::get_multi
Diffstat (limited to 'it_url.class')
-rw-r--r-- | it_url.class | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/it_url.class b/it_url.class index 5e2b681..765a504 100644 --- a/it_url.class +++ b/it_url.class @@ -409,8 +409,7 @@ static function get_multi($p=null) $closehandle($key); } else if($retries[$key]++ < $p['retries']) { $closehandle($key); # closehandle must be called before addhandle as we use the same key - $addhandle($key, $urls[$key]); - $mrc = CURLM_CALL_MULTI_PERFORM; # force continue if this was last handle + $sleepuntils[$key] = microtime(true) + $p['retrysleep']; } else { $results_unordered[$key] = false; unset($urls[$key]); @@ -424,6 +423,16 @@ static function get_multi($p=null) } } } while ($mrc == CURLM_CALL_MULTI_PERFORM); + + foreach ((array)$sleepuntils as $key => $time) { + if (microtime(true) >= $time) { + $addhandle($key, $urls[$key]); + unset($sleepuntils[$key]); + } + $active = 1; + } + usleep($sleepuntils ? 100000 : 0); + $timeout = 0.1; # Longer delay to avoid busy loop but shorter than default of 1s in case we stil hit cURL 7.25.0 problem } |