Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update retrying.py #93

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Update retrying.py #93

wants to merge 1 commit into from

Conversation

Sergfalt
Copy link

Add print_exception attribute for exception printing for every attempt.
For example

####Define functions (before_attempts, after_attempts)####
def print_attemt(attempt):
print(f"Start Attempt # {attempt}")
return attempt

def print_attemt_after(attempt):
print(f"Attempt # {attempt} was failed")
return attempt

Then call a func function with retry (we also can use retry as a decorator with func definition)

retry(stop_max_attempt_number=3,
print_exception=True,
before_attempts=print_attemt, after_attempts=print_attemt_after)(func)(par)

After func call we get the below

Start Attempt # 1
[Errno 2] No such file or directory: 'F:\TEST\test.txt'
Attempt # 1 was failed
Start Attempt # 2
[Errno 2] No such file or directory: 'F:\TEST\test.txt'
Attempt # 2 was failed
Start Attempt # 3
[Errno 2] No such file or directory: 'F:\TEST\test.txt'
Attempt # 3 was failed

Add print_exception attribute for exception printing for every attempt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant