Skip to content

Instantly share code, notes, and snippets.

@k1ic
Created March 2, 2016 03:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save k1ic/d619d078bc429069b205 to your computer and use it in GitHub Desktop.
Save k1ic/d619d078bc429069b205 to your computer and use it in GitHub Desktop.
rety_func
function _retry($function, $params, $max = 3) {
$this->_retry++;
if ($this->_retry >= $max) {
$this->_retry = 0;
Hades_Tool_Log::logRun("p:{$this->_processNumber}|retry_max|function:" . json_encode($function) . "|params:" . json_encode($params), false, __FUNCTION__, $this->_className, Hades_Tool_Log::TYPE_EVE);
return false;
}
usleep(20000);
Hades_Tool_Log::logRun("p:{$this->_processNumber}|retry|count:{$this->_retry}|function:" . json_encode($function) . "|params:" . json_encode($params), false, __FUNCTION__, $this->_className, Hades_Tool_Log::TYPE_EVE);
$result = call_user_func_array($function, $params);
if ($result != false) {
$this->_retry = 0;
}
return $result;
}
$this->_retry(array($this, __FUNCTION__), func_get_args());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment