Skip to content

Commit

Permalink
implement new sleep time
Browse files Browse the repository at this point in the history
  • Loading branch information
ligerlac committed Jan 22, 2024
1 parent 95655e9 commit c53df63
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/realwrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ RealWrapper::RealWrapper(const json& config) {
base_url_ += config["base_url"];
base_url_ += config["api_res"];
n_retries_ = config["n_retries"];
retry_sleep_mean_ = config["retry_sleep_mean"];
}

void RealWrapper::sleep(int retry_number) {
int n_sleep = int(std::exp(retry_number));
srand(time(0));
int n_sleep = rand()%(retry_sleep_mean_*2)+1; // add random sleep
logging::debug("sleeping for " + std::to_string(n_sleep) + " seconds before retrying...");
std::this_thread::sleep_for(std::chrono::seconds(n_sleep));
}
Expand Down

0 comments on commit c53df63

Please sign in to comment.