Skip to content

Commit 63fd4ce

Browse files
mercurial: fix the case insensitive matching when handling retry errors (#103)
1 parent 7377c3b commit 63fd4ce

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

libmozevent/mercurial.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,15 @@ class MercurialWorker(object):
313313
Mercurial worker maintaining several local clones
314314
"""
315315

316+
ELIGIBLE_RETRY_ERRORS = [
317+
error.lower()
318+
for error in [
319+
"push failed on remote",
320+
"stream ended unexpectedly",
321+
"error: EOF occurred in violation of protocol",
322+
]
323+
]
324+
316325
def __init__(self, queue_name, queue_phabricator, repositories, skippable_files=[]):
317326
assert all(map(lambda r: isinstance(r, Repository), repositories.values()))
318327
self.queue_name = queue_name
@@ -401,15 +410,10 @@ def is_eligible_for_retry(self, error):
401410
Given a Mercurial error message, if it's an error likely due to a
402411
temporary connection problem, consider it as eligible for retry.
403412
"""
404-
eligible_errors = [
405-
"push failed on remote",
406-
"stream ended unexpectedly",
407-
"error: EOF occurred in violation of protocol",
408-
]
409-
for eligible_message in eligible_errors:
410-
if eligible_message in error:
411-
return True
412-
return False
413+
error = error.lower()
414+
return any(
415+
eligible_message in error for eligible_message in self.ELIGIBLE_RETRY_ERRORS
416+
)
413417

414418
async def handle_build(self, repository, build):
415419
"""
@@ -471,7 +475,7 @@ async def handle_build(self, repository, build):
471475
if isinstance(error_log, bytes):
472476
error_log = error_log.decode("utf-8")
473477

474-
if self.is_eligible_for_retry(error_log.lower()):
478+
if self.is_eligible_for_retry(error_log):
475479
build.retries += 1
476480
# Ensure try is opened
477481
await self.wait_try_available()

0 commit comments

Comments
 (0)