Issue
How do I retry the same requests.get()
after 5 seconds?
The timeout argument ends the program itself if connection is timed out over 5 seconds.
page2 = requests.get(url, timeout=5.000)
Solution
If your's problem is that the requests.get
doesn't wait enough time, you can set the timeout
argument to more then 5 seconds.
If not, as @jheld mention, you can take the approach of the try-except
, like this:
response = None
try:
response = requests.get(SITE_URL, timeout=5)
except requests.exceptions.Timeout:
try:
response = requests.get(SITE_URL, timeout=5)
except requests.exceptions.Timeout:
pass
Answered By - Yuval Pruss
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.