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

Diff of /FigKernelPackages/SSserver.pm

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

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

Legend:
Removed from v.1.13  
changed lines
  Added in v.1.14

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3