I am trying to connect to a server. Sometimes I cannot reach the server and would like to pause for a few seconds before trying again. How would I implement the pause feature in Python. Here is what I have so far. Thank you.
while True:
try:
response = urllib.request.urlopen(http)
except URLError as e:
continue
break
I am using Python 3.2
This will block the thread for 2 seconds before continuing:
import time
time.sleep(2)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With