[Bio] / FigKernelPackages / ACHserver.pm Repository:
ViewVC logotype

Diff of /FigKernelPackages/ACHserver.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.9, Fri Nov 6 22:50:34 2009 UTC revision 1.10, Wed Nov 25 20:09:40 2009 UTC
# Line 267  Line 267 
267      my $ua = $self->{ua};      my $ua = $self->{ua};
268      # Request the function from the server. Note that the hash is actually passed      # Request the function from the server. Note that the hash is actually passed
269      # as a list reference.      # as a list reference.
270    
271        #
272        # retries is the set of retry wait times in seconds we should use. when
273        # we run out the call will fail.
274        #
275    
276        my @retries = (1, 2, 5, 10, 20, 60, 60, 60, 60, 60, 60);
277        my %codes_to_retry =  map { $_ => 1 } qw(110 408 502 503 504 200) ;
278    
279        while (1)
280        {
281      my $response = $ua->post($self->{server_url}, [ %parms ]);      my $response = $ua->post($self->{server_url}, [ %parms ]);
282      # Get the response content.  
283            if ($response->is_success)
284            {
285      my $retVal = $response->content;      my $retVal = $response->content;
     # Fail if there was an error.  
     if (! $response->is_success) {  
         die ErrorMessage->new($retVal, $response->status_line);  
     }  
     # Return the result.  
286      return $retVal;      return $retVal;
287  }  }
288    
289            #
290            # If this is not one of the error codes we retry for, or if we
291            # are out of retries, fail immediately
292            #
293            my $code = $response->code;
294            if (!$codes_to_retry{$code} || @retries == 0)
295            {
296                die ErrorMessage->new($response->content, $response->status_line);
297            }
298    
299            #
300            # otherwise, sleep & loop.
301            #
302            my $retry_time = shift(@retries);
303            print STDERR "Request failed with code=$code, sleeping $retry_time and retrying\n";
304            sleep($retry_time);
305    
306        }
307    
308        #
309        # Should never get here.
310        #
311    }
312    
313    
314  1;  1;

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.10

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3