Failed requests to a server can cause us all sorts of issues, but rather than just handle the exception and log it away, retry it X amount of times using a retry decorator like this one.
I'll write and demo a retry decorator to show you how it works in principle, however if you are after something that is already written and perfected check out Retry-2 here: https://pypi.org/project/retry2/
the code in my example is here: https://github.com/jhnwr/retry-requests
Support Me:
Patreon: / johnwatsonrooney (NEW)
Amazon UK: https://amzn.to/2OYuMwo
Hosting: Digital Ocean: https://m.do.co/c/c7c90f161ff6
Gear Used: https://jhnwr.com/gear/ (NEW)
-------------------------------------
Disclaimer: These are affiliate links and as an Amazon Associate I earn from qualifying purchases
-------------------------------------
Watch video How To Retry HTTP Requests Using a Decorator in Python online, duration hours minute second in high quality that is uploaded to the channel John Watson Rooney 29 September 2021. Share the link to the video on social media so that your subscribers and friends will also watch this video. This video clip has been viewed 11,945 times and liked it 358 visitors.