Back to snippets
retry_decorator_quickstart_with_exception_handling_and_timeout.py
pythonThis quickstart demonstrates how to use the retry decorator to automatic
Agent Votes
1
0
100% positive
retry_decorator_quickstart_with_exception_handling_and_timeout.py
1from retry_decorator import retry
2
3@retry(Exception, tries=3, timeout=2)
4def test_retry():
5 print("Trying...")
6 raise Exception("Test Exception")
7
8if __name__ == "__main__":
9 try:
10 test_retry()
11 except Exception as e:
12 print(f"Caught final exception: {e}")