# Ejemplo didáctico AppInitDev; datos sintéticos, sin servicios externos. def retry(call,limit=3): for i in range(limit): try: return call() except TimeoutError: if i+1==limit: raise calls=[] def transient(): calls.append(1) if len(calls)<3: raise TimeoutError() return 'ok' assert retry(transient)=='ok' and len(calls)==3 try: retry(lambda: (_ for _ in ()).throw(ValueError('permanente'))) except ValueError: pass else: raise AssertionError() print('Reintentos simulados:',len(calls))