class_docstr: Decorator for flaky tests. Test is run up to ntries times, retrying on failure.
  
  :param ntries:
      the number of tries to attempt
  :param log_retry:
      if True, prints to stdout on retry to avoid being seen as "hanging"
  
  On the last time, the test will simply fail.
  
  >>> @retry(ntries=10)
  ... def test_flaky(self):
  ...     import random
  ...     self.assertLess(0.5, random.random())
class_docstr_tok: ["Decorator","for","flaky","tests",".","Test","is","run","up","to","ntries","times",",","retrying","on","failure",".",":","param","ntries",":","the","number","of","tries","to","attempt",":","param","log_retry",":","if","True",",","prints","to","stdout","on","retry","to","avoid","being","seen","as","``","hanging","''","On","the","last","time",",","the","test","will","simply","fail",".",">",">",">","@","retry","(","ntries=10",")","...","def","test_flaky","(","self",")",":","...","import","random","...","self.assertLess","(","0.5",",","random.random","(",")",")"]
code: def __init__(self, ntries=3, log_retry=False):
      self.ntries = ntries
      self.log_retry = log_retry
  
imports: import os
  import unittest
  import contextlib
  import tempfile
  import shutil
  import io
  import signal
  from typing import Tuple, Dict, Any
  from parlai.core.opt import Opt
  import parlai.utils.logging
  from parlai.utils.io import PathManager
  from pytest_regressions.data_regression import DataRegressionFixture
label_desc: Use image node_id 1 to create a new retry object from inherited base classes: object with example: obj = retry(ntries, log_retry)