Skip to content

Commit 5dab061

Browse files
Emanuele Altierifacebook-github-bot
authored andcommitted
Avoid unlimited connection retries in legacy Python tests
Summary: Unlimited retries may cause these tests to timeout, and timeouts are treated as "warnings" instead of failures by sandcastle. This is why in D69486336 we don't see any test failures. {F1980854862} Differential Revision: D79469055 fbshipit-source-id: 837aaeee3765845934e4a4f0e57de19580109f64
1 parent 7964eae commit 5dab061

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

third-party/mcrouter/src/mcrouter/test/MCProcess.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ def __init__(
165165
# memcached could take little longer to initialize
166166
if memcached:
167167
time.sleep(3)
168-
self.max_retries = max_retries
168+
self.max_retries = 20 if max_retries is None else max_retries
169169
self.deletes = 0
170170
self.others = 0
171171
self.socket = None
@@ -224,13 +224,15 @@ def ensure_connected(self):
224224
self.connect()
225225
break
226226
except Exception as e:
227-
print(f"Caught exception while connect. errno: {e.errno}")
227+
retry_count += 1
228+
print(
229+
f"Cannot connect (errno: {e.errno}). Retry {retry_count} of {self.max_retries}."
230+
)
228231
self.disconnect()
229232
if not self.is_alive():
230233
print("Process exited unexpectedly!")
231234
self.terminate() # This will print logs as well
232235
raise
233-
retry_count += 1
234236
# If we defined a retry count, retry until that's exceeded.
235237
if not self.max_retries or retry_count < self.max_retries:
236238
time.sleep(1)

0 commit comments

Comments
 (0)