Using _retry(..) for IM post updates
Publish PHP Package / docker (push) Successful in 6s Details

This commit is contained in:
Pavel Shevaev 2024-09-26 11:30:34 +03:00
parent 7c3f74772e
commit 037ab21fae
2 changed files with 12 additions and 7 deletions

View File

@ -114,17 +114,17 @@ function _try_lz4_replay(string $txt)
return "4:" . base64_encode(lz4_compress(base64_decode($txt)));
}
function log($msg)
function log(string $msg)
{
echo date("Y-m-d H:i:s") . " " . $msg . "\n";
}
function err($msg)
function err(string $msg)
{
taskman\stderr(date("Y-m-d H:i:s") . " " . $msg . "\n");
}
function _retry($max_tries, $func)
function _retry(int $max_tries, callable $func, int $sleep = 1)
{
for($i=0;$i<$max_tries;++$i)
{
@ -133,12 +133,12 @@ function _retry($max_tries, $func)
$func();
return;
}
catch(Exception $e)
catch(\Throwable $e)
{
if(($i+1) == $max_tries)
throw $e;
}
sleep(1);
sleep($sleep);
}
}

View File

@ -254,7 +254,9 @@ class Plan
try
{
//let's not exit the testing just because we couldn't update IM thread for some reason
_retry(3, function() {
$this->_updateMessengerThread(false);
});
}
catch(\Throwable $e)
{
@ -296,7 +298,10 @@ class Plan
}
}
_retry(3, function() {
$this->_updateMessengerThread(true);
}
);
});
}