Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Retry After Exception
#2
I think you just want to do this:
@retry(stop=stop_after_attempt(2))
def starting()
There is a lot wrong going on in this bit of code.
print(f"In The Hexadecimal Form: %s" %(int(deci)))
print(f"In The Binary Form: %s" %(bin(int(deci,16))))
Your print format is all messed up. Read this:

https://docs.python.org/3/tutorial/inputoutput.html

Why are you using ast to convert a string to an integer? Immediately after you use int() which will generate an exception, which is what you installed tenacity to handle. Why not do this:
intval = int(inputstr, base)
print(f'In The Hexadecimal Form: {hex(intval)}')
print(f'In The Binary Form: {bin(intval)}')
Where base is 16 for hexicecimal, 8 for octal and 2 for binary.
Reply


Messages In This Thread
Retry After Exception - by Harshil - Aug-09-2020, 01:24 PM
RE: Retry After Exception - by deanhystad - Aug-09-2020, 03:20 PM
RE: Retry After Exception - by Harshil - Aug-09-2020, 05:32 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Question Use function, retry until valid Ashcora 8 1,561 Jan-06-2023, 10:14 AM
Last Post: Ashcora
  How to ignore "Retrying (Retry(total=2, connect=2, read=5, redirect=5, status=None))" const 3 2,811 Mar-26-2022, 08:55 AM
Last Post: ndc85430
  requests_futures.sessions retry list of HTTP 429 Johanoosterwaal 0 1,586 Nov-20-2020, 09:23 PM
Last Post: Johanoosterwaal
  How can I fix this code so if i want to retry, it will go through the same loop SteampunkMaverick12 1 1,921 Apr-15-2019, 07:36 PM
Last Post: ichabod801
  During handling of the above exception, another exception occurred Skaperen 7 27,008 Dec-21-2018, 10:58 AM
Last Post: Gribouillis

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020