@@ -396,6 +396,21 @@ def get_status():
396396 )
397397 await asyncio .sleep (TRY_STATUS_DELAY )
398398
399+ def is_eligible_for_retry (self , error ):
400+ """
401+ Given a Mercurial error message, if it's an error likely due to a
402+ temporary connection problem, consider it as eligible for retry.
403+ """
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+
399414 async def handle_build (self , repository , build ):
400415 """
401416 Try to load and apply a diff on local clone
@@ -456,21 +471,7 @@ async def handle_build(self, repository, build):
456471 if isinstance (error_log , bytes ):
457472 error_log = error_log .decode ("utf-8" )
458473
459- def is_eligible_for_retry (error ):
460- """
461- Given a Mercurial error message, if it's an error likely due to a temporary connection problem, consider it as eligible for retry.
462- """
463- eligible_errors = [
464- "push failed on remote" ,
465- "stream ended unexpectedly" ,
466- "error: EOF occurred in violation of protocol" ,
467- ]
468- for eligible_message in eligible_errors :
469- if eligible_message in error_log :
470- return True
471- return False
472-
473- if is_eligible_for_retry (error_log .lower ()):
474+ if self .is_eligible_for_retry (error_log .lower ()):
474475 build .retries += 1
475476 # Ensure try is opened
476477 await self .wait_try_available ()
0 commit comments