Mercurial > hg > ywww
diff xml/amazonBookSearch.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/xml/amazonBookSearch.php Thu Oct 25 09:40:25 2018 -0400 +++ b/xml/amazonBookSearch.php Thu Oct 25 09:42:12 2018 -0400 @@ -93,6 +93,17 @@ curl_setopt ($crl, CURLOPT_ENCODING , "gzip"); curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, $timeout); + $gotit=0; + $semaphore = new SyncSemaphore("Amazon"); + $gotit = $semaphore->lock(4000); + file_put_contents('/var/ywww/debug/phpDebug', + "Got it: ".(int)$gotit." 3\n",FILE_APPEND); + if (!$gotit) { $gotit = $semaphore->lock(20000); } $ret = curl_exec($crl); curl_close($crl); + if ($gotit) { + usleep(1000000); + file_put_contents('/var/ywww/debug/phpDebug',"Unlocking 3\n",FILE_APPEND); + $semaphore->unlock(); + } echo $ret;
