in reply to How do I prevent more than one request (to some URL) per second with CGI?
The code is untested and may not work if you simply cut and paste it. It should, however, give you an idea of how to approach the problem.use Fcntl ':flock'; my $file = 'file.lck'; open my $lfh, ">>$file" or die "Can't access $file : $!\n"; if (flock $lfh, LOCK_EX){ sleep 1 while (time - (stat $file)[9] < 1); # # Send your Amazon requests here # utime time, time, $file; }else{ print "Can't lock $file: $!"; } close $lfh;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: How do I prevent more than one request (to some URL) per second with CGI?
by Balandar (Acolyte) on Nov 27, 2002 at 21:07 UTC | |
by rob_au (Abbot) on Nov 27, 2002 at 23:35 UTC |