Mercurial > hg > ywww
diff php/read/similar.php @ 21:46382face560
use a semaphore to try to cut down on RequestThrottled fails
author | Charlie Root |
---|---|
date | Thu, 25 Oct 2018 09:42:12 -0400 |
parents | ae1459564f66 |
children | d606320ec331 |
line wrap: on
line diff
--- a/php/read/similar.php Thu Oct 25 09:40:25 2018 -0400 +++ b/php/read/similar.php Thu Oct 25 09:42:12 2018 -0400 @@ -106,8 +106,26 @@ curl_setopt ($crl, CURLOPT_URL,$url); curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, $timeout); + $gotit=0; + $semaphore = new SyncSemaphore("Amazon"); + $gotit = $semaphore->lock(4000); + if (!$gotit) { + file_put_contents('/var/ywww/debug/phpDebug', + "Got it: ".(int)$gotit." 4\n",FILE_APPEND); + $gotit = $semaphore->lock(5000); + file_put_contents('/var/ywww/debug/phpDebug', + "Got it: ".(int)$gotit." $requestIP 4a\n",FILE_APPEND); + } $ret = curl_exec($crl); curl_close($crl); + usleep(1000000); + if ($gotit) { + $semaphore->unlock(); + } + else { + file_put_contents('/var/ywww/debug/phpDebug', + "Unlocking 4\n",FILE_APPEND); + } //echo $ret; $xml = new SimpleXMLElement($ret);