From 037ab21fae77975aaa8d168c10929d626160d2cb Mon Sep 17 00:00:00 2001 From: Pavel Shevaev Date: Thu, 26 Sep 2024 11:30:34 +0300 Subject: [PATCH] Using _retry(..) for IM post updates --- atf.inc.php | 10 +++++----- plan.inc.php | 9 +++++++-- 2 files changed, 12 insertions(+), 7 deletions(-) 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); + } + ); }); }