Set the timeout parameter:
r = requests.get(w, verify=False, timeout=10) # 10 seconds
As long as you don't set stream=True
on that request, this will cause the call to requests.get()
to timeout if the connection takes more than ten seconds, or if the server doesn't send data for more than ten seconds.