diff --git a/atf.inc.php b/atf.inc.php index 73f1011..e067cf2 100644 --- a/atf.inc.php +++ b/atf.inc.php @@ -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); } } diff --git a/plan.inc.php b/plan.inc.php index 626f84a..091fe18 100644 --- a/plan.inc.php +++ b/plan.inc.php @@ -254,7 +254,9 @@ class Plan try { //let's not exit the testing just because we couldn't update IM thread for some reason - $this->_updateMessengerThread(false); + _retry(3, function() { + $this->_updateMessengerThread(false); + }); } catch(\Throwable $e) { @@ -296,7 +298,10 @@ class Plan } } - $this->_updateMessengerThread(true); + _retry(3, function() { + $this->_updateMessengerThread(true); + } + ); }); }