Skip to content

Commit 4a91962

Browse files
NathanielVolfangojenkins
authored andcommitted
QPR-10445 -- Fix retry sleep time calculations
1 parent ddafc4d commit 4a91962

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

OREData/ored/utilities/fileio.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,12 @@ FILE* FileIO::fopen(const char* filename, const char* mode) {
6767

6868
for (Size i = 0; i <= maxRetries(); i++) {
6969
if (i > 0) {
70-
int backoffMillis = currentBackoff * 1000;
7170
auto em = EventMessage("Error opening file '" + std::string(filename) + "'. Retrying...");
7271
em.set("retry_count", i);
72+
Real backoffMillis = currentBackoff * 1000;
7373
em.set("retry_interval", backoffMillis);
7474
WLOG(em);
75-
std::this_thread::sleep_for(std::chrono::milliseconds(backoffMillis));
75+
std::this_thread::sleep_for(std::chrono::duration<Real>(currentBackoff));
7676
Real nextBackoff = currentBackoff * 2;
7777
currentBackoff = (nextBackoff >= maxBackoff()) ? maxBackoff() : nextBackoff;
7878
}
@@ -91,12 +91,12 @@ bool FileIO::create_directories(const path& p) {
9191

9292
for (Size i = 0; i <= maxRetries(); i++) {
9393
if (i > 0) {
94-
int backoffMillis = currentBackoff * 1000;
9594
auto em = EventMessage("Error creating directory '" + p.string() + "'. Retrying...");
9695
em.set("retry_count", i);
96+
Real backoffMillis = currentBackoff * 1000;
9797
em.set("retry_interval", backoffMillis);
9898
WLOG(em);
99-
std::this_thread::sleep_for(std::chrono::milliseconds(backoffMillis));
99+
std::this_thread::sleep_for(std::chrono::duration<Real>(currentBackoff));
100100
Real nextBackoff = currentBackoff * 2;
101101
currentBackoff = (nextBackoff >= maxBackoff()) ? maxBackoff() : nextBackoff;
102102
}
@@ -118,12 +118,12 @@ bool FileIO::remove_all(const path& p) {
118118

119119
for (Size i = 0; i <= maxRetries(); i++) {
120120
if (i > 0) {
121-
int backoffMillis = currentBackoff * 1000;
122121
auto em = EventMessage("Error emptying directory '" + p.string() + "'. Retrying...");
123122
em.set("retry_count", i);
123+
Real backoffMillis = currentBackoff * 1000;
124124
em.set("retry_interval", backoffMillis);
125125
WLOG(em);
126-
std::this_thread::sleep_for(std::chrono::milliseconds(backoffMillis));
126+
std::this_thread::sleep_for(std::chrono::duration<Real>(currentBackoff));
127127
Real nextBackoff = currentBackoff * 2;
128128
currentBackoff = (nextBackoff >= maxBackoff()) ? maxBackoff() : nextBackoff;
129129
}

0 commit comments

Comments
 (0)