Skip to content

Commit

Permalink
Removed recursion, make request 3 times in no success
Browse files Browse the repository at this point in the history
  • Loading branch information
wilke committed Aug 22, 2019
1 parent e478a48 commit a944de8
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions lib/PipelineAWE.pm
Original file line number Diff line number Diff line change
Expand Up @@ -244,17 +244,26 @@ sub post_data {
# $req->header('host' => $host);
# }

# try 3 times

$post_attempt = 0;
$req->content($json->encode($data));
my $resp = $agent->request($req);

# try 3 times
if (($post_attempt < 3) && (! $resp->is_success)) {
while( ($post_attempt < 3) && (! $resp->is_success) ) {
logger('error', "posting to $url ($post_attempt): ". $resp->decoded_content );
$post_attempt += 1;
post_data($url, $token, $data);
sleep(5 * $post_attempt);
$resp = $agent->request($req);
}

# if (($post_attempt < 3) && (! $resp->is_success)) {
# $post_attempt += 1;
# post_data($url, $token, $data);
# }

# success or gave up
$post_attempt = 0;

my $content = undef;
eval {
$content = $json->decode( $resp->decoded_content );
Expand Down

0 comments on commit a944de8

Please sign in to comment.